Skip Menu |

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

Report information
The Basics
Id: 52762
Status: resolved
Priority: 0/
Queue: XML-Bare

People
Owner: cpan [...] codechild.com
Requestors: mar.kolya [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.45
Fixed in: 0.49



Subject: XML::Simple compatibility mode doesn't support CDATA with attributes
In case there is an tag with CDATA contents and some attribute result is not the same as in XML::Simple. See patch attached for fix and test with example of a problem. Thanks.
Subject: patch.diff
diff -rub ./XML-Bare-0.45/Bare.xs ./XML-Bare-0.45.new/Bare.xs --- ./XML-Bare-0.45/Bare.xs 2009-08-02 17:12:19.000000000 -0400 +++ ./XML-Bare-0.45.new/Bare.xs 2009-12-14 16:27:29.633359691 -0500 @@ -227,6 +227,10 @@ if( i != ( length - 1 ) ) curnode = curnode->next; } curnode = curnode->parent; + } else { + SV * sv = newSVpvn( curnode->value, curnode->vallen ); + SvUTF8_on(sv); + hv_store( output, "content", 7, sv, vhash ); } if( numatts ) { @@ -258,6 +262,7 @@ SV * xml2obj_simple() CODE: + PERL_HASH(vhash, "content", 7); curnode = parser->pcurnode; RETVAL = cxml2obj_simple(); OUTPUT: diff -rub ./XML-Bare-0.45/t/Basic.t ./XML-Bare-0.45.new/t/Basic.t --- ./XML-Bare-0.45/t/Basic.t 2009-08-02 17:10:02.000000000 -0400 +++ ./XML-Bare-0.45.new/t/Basic.t 2009-12-14 16:31:24.529039034 -0500 @@ -30,6 +30,10 @@ is( $root->{xml}->{node}->{value}, '<cval>', 'reading of cdata' ); is( $simple->{node}, '<cval>', 'simple - reading of cdata' ); +( $xml, $root, $simple ) = reparse( "<xml><node att=\"12\"><![CDATA[<cval>]]></node></xml>" ); +is( $root->{xml}->{node}->{value}, '<cval>', 'reading of cdata' ); +is( $simple->{node}->{content}, '<cval>', 'simple - reading of cdata' ); + ( $xml, $root, $simple ) = reparse( "<xml><node>a</node><node>b</node></xml>" ); is( $root->{xml}->{node}->[1]->{value}, 'b', 'multiple node array creation' ); is( $simple->{node}[1], 'b', 'simple - multiple node array creation' );
This has been corrected in 0.49, which will be out shortly. Note that the changes made only take effect in the case of a cdata node being present ( which is different than the presented patch ). A test case to ensure this works in this way has been added as well. Thanks for your input.