Skip Menu |
 

This queue is for tickets about the URI CPAN distribution.

Report information
The Basics
Id: 96337
Status: open
Priority: 0/
Queue: URI

People
Owner: Nobody in particular
Requestors: polgab [...] cpan.org
Cc: VKHERA [...] cpan.org
AdminCc:

Bug Information
Severity: Important
Broken in: 1.60
Fixed in: (no value)



Subject: In URI::QueryParam, the 'query_param_append' method can't append several UTF8 params.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
Message-ID: <rt-4.0.18-25026-1402299137-476.0-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1402299137-25026-2"
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
Content-Length: 437
Download (untitled) / with headers
text/plain 437b
Hello, In URI::QueryParam, the 'query_param_append' method can't append several UTF8 params. Each previous UTF8 param is badly reencoded. My example script produces: http://www.example.com?a=%C3%A9 at ./bug-uri.pl line 10. http://www.example.com?a=%C3%83%C2%A9&b=%C3%A9 at ./bug-uri.pl line 12. Instead of: http://www.example.com?a=%C3%A9 at ./bug-uri.pl line 10. http://www.example.com?a=%C3%A9&b=%C3%A9 at ./bug-uri.pl line 12.
Subject: bug-uri.pl
MIME-Version: 1.0
Content-Type: application/x-perl; name="bug-uri.pl"
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline; filename="bug-uri.pl"
Content-Transfer-Encoding: base64
Content-Length: 249
Download bug-uri.pl
text/x-perl 249b
#!/usr/bin/perl # -*- coding: utf-8; -*- use strict; use warnings; use utf8; use URI; use URI::QueryParam; my $uri = URI->new("http://www.example.com"); $uri->query_param_append(a => "é"); warn $uri; $uri->query_param_append(b => "é"); warn $uri;
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-25026-1402299137-476.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-25026-1402299137-476.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-2124-1449435179-1008.96337-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 1370
Download (untitled) / with headers
text/plain 1.3k
On 2014-06-09 03:32:17, POLGAB wrote: Show quoted text
> Hello, > > In URI::QueryParam, the 'query_param_append' method can't append > several UTF8 params. Each previous UTF8 param is badly reencoded. > > My example script produces: > > http://www.example.com?a=%C3%A9 at ./bug-uri.pl line 10. > http://www.example.com?a=%C3%83%C2%A9&b=%C3%A9 at ./bug-uri.pl line > 12. > > Instead of: > > http://www.example.com?a=%C3%A9 at ./bug-uri.pl line 10. > http://www.example.com?a=%C3%A9&b=%C3%A9 at ./bug-uri.pl line 12.
It seems that URI::QueryParam has no notion about handling "wide characters" at all. The following test script fails, but it should not (a perl program should behave the same regardless whether the utf8 flag is set or unset): #!perl use strict; use Test::More 'no_plan'; use URI; use URI::QueryParam; my $val = "\xe4"; my $uri_noflag = URI->new("http://www.example.com"); $uri_noflag->query_param_append(a => $val); utf8::upgrade $val; my $uri_flag = URI->new("http://www.example.com"); $uri_flag->query_param_append(a => $val); is $uri_flag, $uri_noflag; __END__ Output is: not ok 1 # Failed test at /tmp/utf8.pl line 12. # got: 'http://www.example.com?a=%C3%A4' # expected: 'http://www.example.com?a=%E4' 1..1 # Looks like you failed 1 test of 1. Probably currently the best which can be done is to encode the param keys and values manually.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-25026-1402299137-476.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-25026-1402299137-476.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-11629-1449435300-892.96337-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 578
Download (untitled) / with headers
text/plain 578b
On 2014-06-09 03:32:17, POLGAB wrote: Show quoted text
> Hello, > > In URI::QueryParam, the 'query_param_append' method can't append > several UTF8 params. Each previous UTF8 param is badly reencoded. > > My example script produces: > > http://www.example.com?a=%C3%A9 at ./bug-uri.pl line 10. > http://www.example.com?a=%C3%83%C2%A9&b=%C3%A9 at ./bug-uri.pl line > 12. > > Instead of: > > http://www.example.com?a=%C3%A9 at ./bug-uri.pl line 10. > http://www.example.com?a=%C3%A9&b=%C3%A9 at ./bug-uri.pl line 12.
Possibly related ticket: https://rt.cpan.org/Ticket/Display.html?id=53681


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.