Skip Menu |
 

This queue is for tickets about the SVG-Parser CPAN distribution.

Report information
The Basics
Id: 13577
Status: open
Priority: 0/
Queue: SVG-Parser

People
Owner: peter [...] cybrid.net
Requestors: tt [...] loopone.com
Cc:
AdminCc:

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



Subject: Entites in text sections cause loss of data.
Download (untitled) / with headers
text/plain 916b
If you have a text section in your xml like so: <tag>A &amp; B</tag> The expat parser will break that up into 3 cdata sections 'A ', '&', and ' B'. Currently the way the SVG::Parser::Expat::Text function is written each one of those cdata sections will overwrite the previous section so you'll end up with the data ' B'. Here's the fix I'm using. I'm not especially knowledgable about how the expat parser works so I figured that rather than a patch I'd just provide example code: *{SVG::Parser::Expat::Text} = sub { my ($parser,$expat,$text)=@_; my $elements=$parser->{__elements}; return if $text=~/^\s*$/s; #ignore redundant whitespace my $parent=$elements->[-1]; use Data::Dumper; if(defined $parent->{-cdata}) { $text = $parent->{-cdata} . $text; } $parent->cdata($text); $parser->debug("CDATA","\"$text\""); };
From: tim [...] loadedguntheory.com
[guest - Thu Jul 7 10:51:50 2005]: That should be <tag>A &amp;amp; B</tag> Show quoted text
> If you have a text section in your xml like so: > > <tag>A &amp; B</tag> > > The expat parser will break that up into 3 cdata sections 'A ', '&', > and ' B'. Currently the way the SVG::Parser::Expat::Text function > is written each one of those cdata sections will overwrite the > previous section so you'll end up with the data ' B'. Here's the > fix I'm using. I'm not especially knowledgable about how the expat > parser works so I figured that rather than a patch I'd just provide > example code: > > *{SVG::Parser::Expat::Text} = sub { > my ($parser,$expat,$text)=@_; > my $elements=$parser->{__elements}; > > return if $text=~/^\s*$/s; #ignore redundant whitespace > my $parent=$elements->[-1]; > use Data::Dumper; > > if(defined $parent->{-cdata}) { > $text = $parent->{-cdata} . $text; > } > $parent->cdata($text); > > $parser->debug("CDATA","\"$text\""); > };
Download (untitled) / with headers
text/plain 312b
This problem appears to have been resolved by changes made to the SVG.pm module itself -- I cannot reproduce it with using SVG::Parser with a modern release of SVG. (Please note that a new version of SVG::Parser has just been uploaded to CPAN. It does not contain any changes is related to this ticket, however.)


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.