Subject: | v1.04 incorrectly escaping stringified inner tags |
Date: | Thu, 18 Oct 2012 17:42:17 -0700 (GMT+7) |
To: | bug-XML-Generator [...] rt.cpan.org |
From: | Fred Morris <m3047 [...] m3047.net> |
There seems to be some undesirable interaction between
conformance => 'strict'
and the invalid character filtering in v1.04 as it pertains to stringified
inner tag data:
fred.morris@portal:~$ perl -we 'use strict; use XML::Generator; my $XML =
XML::Generator->new(conformance => "strict"); printf "%s\n",
$XML->record(join "\n", map { my ($k, $v) = @{$_}; $XML->$k($v); }
([threat => 1], [desc => "godzilla"], [value =>
"http://y.ahoooooooooo.it/0weifjwef"], [detected => "2012-10-16 00:00:00"]));'
<record><threat>1</threat>
<desc>godzilla</desc>
<value>http://y.ahoooooooooo.it/0weifjwef</value>
<detected>2012-10-16 00:00:00</detected></record>
As you can see, only the "<" is escaped which seems odd.
If we eliminate the conformance flag, the output looks correct:
fred.morris@portal:~$ perl -we 'use strict; use XML::Generator; my $XML =
XML::Generator->new(); printf "%s\n", $XML->record(join "\n", map { my
($k, $v) = @{$_}; $XML->$k($v); } ([threat => 1], [desc => "gozdilla"],
[value => "http://y.ahoooooooooo.it/0weifjwef"], [detected => "2012-10-16 00:00:00"]));'
<record><threat>1</threat>
<desc>godzilla</desc>
<value>http://y.ahoooooooooo.it/0weifjwef</value>
<detected>2012-10-16 00:00:00</detected></record>
Likewise, if we disable the "invalid" character filtering the output looks
correct:
fred.morris@portal:~$ perl -we 'use strict; use XML::Generator; my $XML =
XML::Generator->new(conformance => "strict", filter_invalid_chars => 0);
printf "%s\n", $XML->record(join "\n", map { my ($k, $v) = @{$_};
$XML->$k($v); } ([threat => 1], [desc => "godzilla"], [value =>
"http://y.ahoooooooooo.it/0weifjwef"], [detected => "2012-10-16 00:00:00"]));'
<record><threat>1</threat>
<desc>godzilla</desc>
<value>http://y.ahoooooooooo.it/0weifjwef</value>
<detected>2012-10-16 00:00:00</detected></record>
Furthermore if we stop stringifying the inner tags and let it consume its
own spawn, all is well:
fred.morris@portal:~$ perl -we 'use strict; use XML::Generator; my $XML =
XML::Generator->new(conformance => "strict", pretty => 1); printf "%s\n",
$XML->record(map { my ($k, $v) = @{$_}; $XML->$k($v); } ([threat => 1],
[desc => "godzilla"], [value => "http://y.ahoooooooooo.it/0weifjwef"],
[detected => "2012-10-16 00:00:00"]));'
<record>
<threat>1</threat>
<desc>godzilla</desc>
<value>http://y.ahoooooooooo.it/0weifjwef</value>
<detected>2012-10-16 00:00:00</detected>
</record>
This is Linux with Perl 5.10. Version 1.03 does not exhibit this behavior.
I thought I'd file this to at least highlight the work-arounds.
--
Fred Morris
m3047 [at] m3047.net