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.
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
#!/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;
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.
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