Skip Menu |

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

Report information
The Basics
Id: 16397
Status: resolved
Priority: 0/
Queue: XML-SAX

People
Owner: Nobody in particular
Requestors: mcrawfor [...] u.washington.edu
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.13
Fixed in: 0.12



Subject: CDATA blocks have extra >
When I have the following XML: <btn name="profile_manage" title="Manage Profile"><![CDATA[Manage Profile]]></btn> <btn name="profile_save" title="Save"><![CDATA[Save]]></btn> <btn name="tab_all_projects" title="All projects listed here"><![CDATA[All Projects]]></btn> And parse it (first with XML::Simple, then directly) the content of these elements comes out as "Manage Profile>" "Save>" etc. Reverting to XML::SAX 0.12 fixes this. Thanks, -miles
Sorry - I should have left only 0.12 selected for "Fixed in." I haven't checked it in any other versions.
From: Perlover
Hi! Please verify what parser do you use? If you use ParseFactory you need to see ParserDetails.ini (last parser section tells what parser should be used). ParserDetails.ini is located anywhere in perl directories (# locate ParserDetails.ini) This bug as i think is bug of parser. The default PurePerl parser doesn't have this bug: From PurePerl.pm, 316 line: if ($data =~ /^(.*?)\]\]>/s) { my $chars = $1; $reader->move_along(length($chars) + 2); $self->characters({Data => $chars}); last; } After reinstalling you ParserDetails.ini to be changed and i think this is main reason of disappearance of bug (if you use ParserFactory of course). // Guest aka Perlover
From: Miles
My ParserDetails.ini: [XML::SAX::PurePerl] http://xml.org/sax/features/namespaces = 1 What should it look like for me to test the old method? -miles
From: Miles Crawford
Well, actually, look at that code: Show quoted text
> The default PurePerl parser > doesn't have this bug: > From PurePerl.pm, 316 line: > if ($data =~ /^(.*?)\]\]>/s) { > my $chars = $1; > $reader->move_along(length($chars) + 2); > $self->characters({Data => $chars}); > last; > }
That's what I see in my parser and if you note, it move_alongs the length of the match plus TWO characters. The end of CDATA blocks is three, ]]>, so it's leaving the > on there. Changing the 2 to a three fixes this bug for me. I'll try to find the right place to report. -miles
From: Brett
I can confirm that it is the line in PurePerl.pm The problem did not appear with XML::SAX v0.12 PurePerl v0.9 But it did appear with XML::SAX v0.13 PurePerl v0.9 On Tue Feb 28 16:04:55 2006, guest wrote: Show quoted text
> > Well, actually, look at that code: >
> > The default PurePerl parser > > doesn't have this bug: > > From PurePerl.pm, 316 line: > > if ($data =~ /^(.*?)\]\]>/s) { > > my $chars = $1; > > $reader->move_along(length($chars) + 2); > > $self->characters({Data => $chars}); > > last; > > }
> > That's what I see in my parser and if you note, it move_alongs the > length of the match plus TWO characters. The end of CDATA blocks is > three, ]]>, so it's leaving the > on there. Changing the 2 to a three > fixes this bug for me. I'll try to find the right place to report. > -miles
The attached patch fixes the problem and provides a test case. Bye, Uwe
Index: testfiles/06g.xml =================================================================== --- testfiles/06g.xml (Revision 0) +++ testfiles/06g.xml (Revision 0) @@ -0,0 +1 @@ +<foo><![CDATA[bar]]></foo> Index: t/15element.t =================================================================== --- t/15element.t (Revision 37) +++ t/15element.t (Arbeitskopie) @@ -1,5 +1,5 @@ use Test; -BEGIN { plan tests => 31 } +BEGIN { plan tests => 32 } use XML::SAX::PurePerl; use XML::SAX::PurePerl::DebugHandler; @@ -63,6 +63,10 @@ }; ok($@); +$handler->reset; +$handler->{test_chr}{Data} = "bar"; +$parser->parse_uri("testfiles/06g.xml"); + ## HELPER PACKAGE ## package TestElementHandler; @@ -96,3 +100,14 @@ } } +sub characters { + my ($self, @text) = @_; + if ($self->{test_chr}) { + foreach my $text (@text) { + foreach my $key (keys %{ $self->{test_chr} }) { + #warn $key, "\n"; + ok("$key: $text->{$key}", "$key: $self->{test_chr}{$key}"); + } + } + } +} Index: SAX/PurePerl.pm =================================================================== --- SAX/PurePerl.pm (Revision 37) +++ SAX/PurePerl.pm (Arbeitskopie) @@ -315,7 +315,7 @@ if ($data =~ /^(.*?)\]\]>/s) { my $chars = $1; - $reader->move_along(length($chars) + 2); + $reader->move_along(length($chars) + 3); $self->characters({Data => $chars}); last; }