Skip Menu |
 

This queue is for tickets about the XML-LibXML CPAN distribution.

Report information
The Basics
Id: 53632
Status: resolved
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: daniel.frett [...] ccci.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.70
Fixed in: (no value)



Subject: [patch] $node->normalize stops processing when an empty element node is encountered
Download (untitled) / with headers
text/plain 322b
when calling normalize on a node, processing of children nodes will stop when an empty element node is encountered. Attached is a script demonstrating this behavior and a patch with an updated normalize test and a fix for the issue. domNodeNormalizeList shouldn't return an error when given an empty node list to process.
Subject: normalizeTest.pl
Download normalizeTest.pl
text/x-perl 360b
#!/usr/bin/perl use XML::LibXML; my $doc = XML::LibXML::Document->new(); my $e1 = $doc->createElement('foo'); $e1->addNewChild(undef, 'bar'); $e1->appendChild($doc->createTextNode('bar')) for(1..3); print "Child Nodes before normalize: " . $e1->childNodes->size . "\n"; $e1->normalize; print "Child Nodes after normalize: " . $e1->childNodes->size . "\n";
Subject: libxml-03.patch
Download libxml-03.patch
text/x-diff 1.1k
diff --git a/dom.c b/dom.c index 546108c..686418a 100644 --- a/dom.c +++ b/dom.c @@ -1227,9 +1227,6 @@ domNodeNormalize( xmlNodePtr node ); int domNodeNormalizeList( xmlNodePtr nodelist ) { - if ( nodelist == NULL ) - return(0); - while ( nodelist ){ if ( domNodeNormalize( nodelist ) == 0 ) return(0); diff --git a/t/06elements.t b/t/06elements.t index f6c08a2..13eab05 100644 --- a/t/06elements.t +++ b/t/06elements.t @@ -218,6 +218,8 @@ print "# 4. Text Append and Normalization\n"; my $t2 = $doc->createTextNode( "bar2" ); my $t3 = $doc->createTextNode( "bar3" ); my $e = $doc->createElement("foo"); + my $e2 = $doc->createElement("bar"); + $e->appendChild( $e2 ); $e->appendChild( $t1 ); $e->appendChild( $t2 ); $e->appendChild( $t3 ); @@ -226,12 +228,12 @@ print "# 4. Text Append and Normalization\n"; # this is the correct behaviour for DOM. the nodes are still # refered - ok( scalar( @cn ), 3 ); + ok( scalar( @cn ), 4 ); $e->normalize; @cn = $e->childNodes; - ok( scalar( @cn ), 1 ); + ok( scalar( @cn ), 2 ); ok(not defined $t2->parentNode); ok(not defined $t3->parentNode);
Fixed in XML-LibXML-1.73. Thanks for the patch.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.