Skip Menu |
 

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

Report information
The Basics
Id: 51432
Status: resolved
Priority: 0/
Queue: XML-Twig

People
Owner: Nobody in particular
Requestors: kahn [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 3.32
Fixed in: 3.33



Subject: attributes containing quote character don't escape properly
Download (untitled) / with headers
text/plain 1.1k
As far as I understand the behavior, doing something like: $elt = XML::Twig::Elt->new('baz'); $elt->set_att(foo => '"'); print $elt->sprint(); is perfectly legal. However, this prints something like this: <baz foo="""/> which is illegal XML; XML::Parser barfs on reading this back in. I dug through the code, and as far as I can tell in version 3.33 this is still a problem -- it's because the escapes for replacing things in attribute values don't include the (variable) quote symbol. Luckily, it seems to be a one-line patch to adjust the $replace_in_att_value symbol properly: Patch in Twig.pm (well, Twig_pm.slow in the distribution). +++ Twig_pm.slow~ 2009-08-11 08:06:11.000000000 -0700 @@ -7546,11 +7546,11 @@ my $att_sep = $pretty==$NSGMLS ? "\n" -- ; - my $replace_in_att_value= $replaced_ents . $quote; + my $replace_in_att_value= $replaced_ents; if( $option->{escape_gt} && $replaced_ents !~ m{>}) { $replace_in_att_value.= '>'; } my $tag; my @att_names= grep { !_is_private_name( $_) } $keep_atts_order ? keys %{$att} : sort keys %{$att}; if( @att_names)
Subject: Re: [rt.cpan.org #51432] attributes containing quote character don't escape properly
Date: Wed, 11 Nov 2009 12:58:55 +0100
To: bug-XML-Twig [...] rt.cpan.org
From: mirod <xmltwig [...] gmail.com>
Download (untitled) / with headers
text/plain 510b
Jeremy Kahn via RT wrote: Show quoted text
> As far as I understand the behavior, doing something like: > > $elt = XML::Twig::Elt->new('baz'); > $elt->set_att(foo => '"'); > print $elt->sprint(); > > is perfectly legal. However, this prints something like this: > > <baz foo="""/> > > which is illegal XML; XML::Parser barfs on reading this back in.
Duh! I can't believe I did not test for this. Thanks for the patch, it's now on the development version at the usual place, along with tests. Thanks -- mirod
Fixed in 3.33 __ mirod


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.