Subject: | malformed xml when '&' in hash key |
If your response data has an XML special character like '&' in a key of
a hash, that will not be translated to & yielding a "not well-formed
(invalid token)" error on decoding.
How to reproduce:
use Frontier::RPC2;
my $coder = Frontier::RPC2->new;
my $data={'mykeywith&'=> 1};
my $xml_string = $coder->encode_response($data);
print $xml_string;
my $call = $coder->decode($xml_string);
print Dumper($call);
Attached patch solves the problem for me.
Subject: | RPC2.pm.diff |
--- /usr/share/perl5/Frontier/RPC2.pm 2007-04-30 10:01:46.000000000 +0200
+++ RPC2.pm 2012-01-17 19:11:04.000000000 +0100
@@ -197,6 +197,7 @@
my ($key, $value);
while (($key, $value) = each %$hash) {
+ $key =~ s/([&<>\"])/$char_entities{$1}/ge;
push (@text,
"<member><name>$key</name>",
$self->_item($value),