Skip Menu |

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

Report information
The Basics
Id: 56467
Status: resolved
Priority: 0/
Queue: XML-Tiny

People
Owner: Nobody in particular
Requestors: nick.dumas [...] gmail.com
Cc:
AdminCc:

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



Subject: CDATA including quotes inside an attribute
Date: Sat, 10 Apr 2010 13:10:44 -0400
To: bug-XML-Tiny [...] rt.cpan.org
From: Nick Dumas <nick.dumas [...] gmail.com>
Recently I was again trying to add some perl code to an attribute in the XML, and I was getting "Not Well Formed" despite using CDATA tags to block it off. After some investigation, the parser was tripping over the unreplaced &apos; in "This ship's name". (see sample below) I just added ' and " to the CDATA->PCDATA substitution code, and now it parses happily. (Covers the 5 reserved characters) http://www.w3schools.com/tags/ref_entities.asp There is a note there that IE doesn't like &apos; so it might be good to replace that with &#39; instead. On the other hand, the code is reading, not writing, so IE shouldn't be involved. EG: ============= <object id='SensorProbe'> <attribute name='object type'> <value type='scalar' value='ship'/> </attribute> <attribute name='AIscript'> <value type='scalar' value='<![CDATA[ # Inputs # ~~~~~~ # $self = This ship's name/ID # $library = Hash tree of the mod library. ... ]]> '/> ... ========= Change to XML-tiny: (Line ~190 in tiny.pm) ========= # turn CDATA into PCDATA $file =~ s{<!\[CDATA\[(.*?)]]>}{ $_ = $1.chr(0); # this makes sure that empty CDATAs become s/([&<>'"])/ # the empty string and aren't just thrown away. $1 eq '&' ? '&amp;' : $1 eq '<' ? '&lt;' : $1 eq '"' ? '&quot;' : $1 eq "'" ? '&apos;': '&gt;' /eg; $_; }egs; ========= - Nick (SuicideJunkie on PerlMonks)
Thanks, fixed in 2.04