Subject: | Single quotes in attribute values are not escaped |
Date: | Thu, 12 Nov 2015 19:24:30 -0500 |
To: | bug-XML-Quick [...] rt.cpan.org |
From: | Peter Eichman <peichman [...] cpan.org> |
Attribtue values containing single quotes are not correctly escaped,
leading to invalid XML output.
Test code:
#!/usr/bin/perl -w
use strict;
use XML::Quick;
use Test::More tests => 2;
# one single quote
is(
xml({ foo => { _attrs => { bar => "O'Reilly" }}}),
q{<foo bar='O'Reilly'/>},
);
# multiple single quotes
is(
xml({ foo => { _attrs => { bar => "O'Reilly and O'Toole" }}}),
q{<foo bar='O'Reilly and O'Toole'/>},
);
Run against the current 0.05 version of XML::Quick produces the
following:
1..2
not ok 1
# Failed test at /home/peter/xml-quick-attr-bug line 7.
# got: '<foo bar='O'Reilly'/>'
# expected: '<foo bar='O'Reilly'/>'
not ok 2
# Failed test at /home/peter/xml-quick-attr-bug line 12.
# got: '<foo bar='O'Reilly and O'Toole'/>'
# expected: '<foo bar='O'Reilly and O'Toole'/>'
# Looks like you failed 2 tests of 2.
After applying the attached patch, the test code succeeds.
Version info:
* XML-Quick-0.05
* perl 5.10.0
* Linux grim 2.6.31-23-generic #75-Ubuntu SMP Fri Mar 18 18:08:39 UTC 2011 i686 GNU/Linux
--
peichman@cpan.org
http://github.com/peichman
Message body is not shown because sender requested not to inline it.