Silent removed parameters when posting UTF8

Bill Moseley <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
I have a form that posts to a service, and noticed not all
parameters were being posted.

I realized my mistake of not encoding to utf8, but I'm curious why
this did not generate any warnings.

I can imagine others getting caught by this, so a warning would be very
helpful.

Not really sure where it should be checked -- in query_form when
processing the individual parameters, I suspect, but the damage seems
to happen when $uri->query is called:

    $q =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;

Would it not be better to issue a waring?


use HTTP::Request::Common;
use strict;
use warnings;
use Data::Dumper;
use Encode;

my $content = {
    foo => 'bar',
    count => 123,
    works => encode_utf8("\x{263A}"),
    does_not_work => "\x{263A}",
};

my $x = HTTP::Request::Common::POST(
    'http://localhost.com',
    $content,
);
print Dumper $x;

$VAR1 = bless( {
 '_content' => 'count=123&works=%E2%98%BA&does_not_work=&foo=bar',
 '_uri' => bless( do{\(my $o = 'http://localhost.com')}, 'URI::http' ),
 '_headers' => bless( {
                        'content-type' => 'application/x-www-form-urlencoded',
                        'content-length' => 48
                      }, 'HTTP::Headers' ),
 '_method' => 'POST'
}, 'HTTP::Request' );




-- 
Bill Moseley
[email protected]
Sent from my iMutt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.