Subject: | Patch for URI to handle urls |
Date: | Thu, 4 Nov 2010 16:45:22 -0400 |
To: | <bug-URI [...] rt.cpan.org> |
From: | "John Miller" <john [...] rimmkaufman.com> |
Version: 1.38
Perl Version: 5.8.8 x86_64-linux
OS Version: Gentoo Linux. Kernel 2.6.28-hardened
The _query module does not handle http query strings that are not
<name>=<value> pairs. Code to reproduce:
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use URI;
use URI::QueryParam;
my $u = URI->new('http://sample.com/test.html?foo');
$u->query_param_append('bar', 1);
print $u->as_string, "\n";
$u = URI->new('http://sample.com/test.html?foo&bar=1');
$u->query_form($u->query_form);
print $u->as_string, "\n";
Expected output:
http://sample.com/test.html?foo&bar=1
http://sample.com/test.html?foo&bar=1
Actual output:
http://sample.com/test.html?bar=1
http://sample.com/test.html?foo=&bar=1
Note that in the first string, the foo part of the query portion is dropped.
In the second, an = is appended to the element.
With the attached patch, the output is:
http://sample.com/test.html?foo&bar=1
http://sample.com/test.html?foo&bar=1
As expected.
There is a behavior change. Previously, parameters sent into query_form
with value undef would be set to blank. Now they will be included with no
"=" or value. To set a value to blank, use an empty string -- ''.
Message body is not shown because sender requested not to inline it.