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?

In reply to Strange behaviour in Frontier::Client (scalars vs. hashes) by isync

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.