develooper Front page | perl.libwww | Postings from September 2008

Silent removed parameters when posting UTF8

Thread Next
From:
Bill Moseley
Date:
September 18, 2008 22:54
Subject:
Silent removed parameters when posting UTF8
Message ID:
20080919055456.GC6319@hank.org
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
moseley@hank.org
Sent from my iMutt


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About