isync has asked for the wisdom of the Perl Monks concerning the following question:

Using the Frontier XMLRPC system, I encountered a strange inconsisten encoding of the ampersand. In passed scalars all ampersands are always encoded, like the specification sais. Using this function.
sub _scalar { my $self = shift; my $value = shift; # these are from `perldata(1)' if ($value =~ /^[+-]?\d+$/) { return ("<value><i4>$value</i4></value>"); } elsif ($value =~ /^(-?(?:\d+(?:\.\d*)?|\.\d+)|([+-]?)(?=\d|\.\d) +\d*(\.\d*)?([Ee]([+-]?\d+))?)$/) { return ("<value><double>$value</double></value>"); } else { $value =~ s/([&<>\"])/$char_entities{$1}/ge; return ("<value><string>$value</string></value>"); } }
Now I changed the data structure in my script and passed all data in a hash, where the hash-keys, again, might contain ampersands. Expecting that Frontier would take over encoding for me I saw no problem, but it ran into an error.

As it turned out hash-keys are not automatically encoded.
sub _hash { my $self = shift; my $hash = shift; my @text = "<value><struct>\n"; my ($key, $value); while (($key, $value) = each %$hash) { push (@text, "<member><name>$key</name>", $self->_item($value), "</member>\n"); } push @text, "</struct></value>\n"; return @text; }
But WHY?? Isn't the Frontier module meant to take over the gory details for me? Can somebody give me a good reason for not writing a fork with this bug(?) fixed?

Replies are listed 'Best First'.
Re: Strange behaviour in Frontier::Client (scalars vs. hashes)
by clinton (Priest) on Apr 20, 2007 at 13:52 UTC
    But WHY?? Isn't the Frontier module meant to take over the gory details for me? Can somebody give me a good reason for not writing a fork with this bug(?) fixed?

    Why? probably because the author didn't think of it, and given the bug page he is no longer actively maintaining the module.

    I would consider contacting the author to see if he would like to transfer maintainership of the module, in which case you can fix the other bugs listed against the module. Failing that, write a wrapper to work around the bug.

    You may also want to read the CPAN FAQ entitled How do I go about maintaining a module when the author is unresponsive?.