1. Shlomi Fish
  2. perl-XML-LibXML

Commits

ph...@9ae0c189-cd1f-4510-a509-f4891f5cf20d  committed 874ed1a

Modified Files:
LibXML.xs
+ fixed segfault when XML_ATTRIBUTE_NODE is passed to XML:LibXML::Node::toString
+ XML::LibXML::Node::getData does work correct with XML_ATTRIBUTE_NODE

  • Participants
  • Parent commits ef88968
  • Branches default

Comments (0)

Files changed (1)

File LibXML.xs

View file
  • Ignore whitespace
         const char * content;
     CODE:
         if( node != NULL ) {
-            content = node->content;
+            if ( node->type != XML_ATTRIBUTE_NODE ){
+                content = node->content;
+            }
+            else if ( node->children != NULL ) {
+                content = node->children->content;
+            }
         }
         if ( content != 0 ){
             RETVAL = newSVpvn( (char *)content, xmlStrlen( content ) );
     PREINIT:
         xmlBufferPtr buffer;
     CODE:
-        buffer = xmlBufferCreate();
-        xmlNodeDump( buffer, self->doc, self, 0, 0 );
-        if ( buffer->content != 0 ) {
-            RETVAL = newSVpvn( buffer->content, buffer->use );
+        if ( self->type != XML_ATTRIBUTE_NODE ) {
+            buffer = xmlBufferCreate();
+            xmlNodeDump( buffer, self->doc, self, 0, 0 );
+            if ( buffer->content != 0 ) {
+                RETVAL = newSVpvn( buffer->content, buffer->use );
+            }
+            else {
+                RETVAL = &PL_sv_undef;
+            }
+            xmlBufferFree( buffer );
+        }
+        else if ( self->children != NULL ) {
+            RETVAL =  newSVpvn( self->children->content, 
+                                xmlStrlen( self->children->content) );
         }
         else {
             RETVAL = &PL_sv_undef;
         }
-        xmlBufferFree( buffer );
     OUTPUT:
         RETVAL