Subject: | XML::SAX::Writer::XML encodes ]]> incorrectly in CDATA |
Date: | Wed, 26 Oct 2011 17:31:51 -0400 |
To: | bug-XML-SAX-Writer [...] rt.cpan.org |
From: | John Dalbec <jpdalbec [...] ysu.edu> |
I believe the correct encoding for ]]> is ]]>
sub characters {
...
if ($self->{InCDATA}) {
# we must scan for ]]> in the CDATA and escape it if it
# is present by close--opening
# we need to have buffer text in front of this...
$char = join ']]>]]<<![CDATA[', split ']]>', $char;
}
...
}
use XML::SAX::Writer;
my $writer=XML::SAX::Writer->new();
$writer->start_document();
$writer->start_cdata();
$writer->characters({Data=>"x]]>y"});
$writer->end_cdata();
$writer->end_document();
<![CDATA[x]]>]]<<![CDATA[y]]>