Skip Menu |

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

Report information
The Basics
Id: 17862
Status: rejected
Priority: 0/
Queue: XML-Writer

People
Owner: Nobody in particular
Requestors: marcm [...] lectroid.net
Cc:
AdminCc:

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



Subject: [PATCH] Don't map & to & when already in a valid entity construct
Currently XML writer maps all instances of & to &amp; which is great, unless the & is already in an existing entity. This diff makes XML::Writer leave existing entities alone. --- Writer.pm.orig Sat Feb 25 22:27:21 2006 +++ Writer.pm Sat Feb 25 22:27:46 2006 @@ -342,7 +342,7 @@ my $characters = sub { my $data = $_[0]; if ($data =~ /[\&\<\>]/) { - $data =~ s/\&/\&amp\;/g; + $data =~ s/\&(?!(?:\w|#)+?\;)/\&amp\;/g; $data =~ s/\</\&lt\;/g; $data =~ s/\>/\&gt\;/g; } @@ -744,7 +744,7 @@ sub _escapeLiteral { my $data = $_[0]; if ($data =~ /[\&\<\>\"]/) { - $data =~ s/\&/\&amp\;/g; + $data =~ s/\&(?!(?:\w|#)+?\;)/\&amp\;/g; $data =~ s/\</\&lt\;/g; $data =~ s/\>/\&gt\;/g; $data =~ s/\"/\&quot\;/g;
On Sun Feb 26 01:32:23 2006, guest wrote: Show quoted text
> Currently XML writer maps all instances of & to &amp; which is great, > unless the & is already in an existing entity. This diff makes > XML::Writer leave existing entities alone.
This would be a convenience but, unfortunately breaks double-escaping (needed for RSS and Atom feeds) and could also corrupt text that happened to resemble, or discuss, XML entity syntax. If you have already-escaped markup, try pre-processing with decode_entities from HTML::Escape, for example.