jeffa has asked for the wisdom of the Perl Monks concerning the following question:
Yielded:use URI; use Data::Dumper; my $uri = URI->new('http://localhost/foo.cgi?foo=bar&foo=baz'); my %form_var = $uri->query_form; print Dumper \%form_var;
$VAR1 = {
'foo' => 'baz'
};
So i hunted down query_form() (it is located in
URI/_query.pm) and discovered this at the end
of that subroutine:
Then i decided to recode that with something like this:map { s/\+/ /g; uri_unescape($_) } map { /=/ ? split(/=/, $_, 2) : ($_ => '')} split(/&/, $old);
Now when i run my test code, i get the output i expect:my %hash; for my $pair (split /&/, $old) { my ($k,$v) = map { s/\+/ /g; uri_unescape($_) } split /=/, $pair, 2; if (exists $hash{$k}) { if (ref $hash{$k}) { push @{$hash{$k}}, $v; } else { $hash{$k} = [$hash{$k},$v]; } } else { $hash{$k} = $v; } } return %hash;
$VAR1 = {
'foo' => [
'bar',
'baz'
]
};
The reason i am bringing this up is because i submitted this
as a patch to Gisle Aas and never heard back. The bug has
been
'resolved',
but my test case is contrary ...
Is this really a 'bug' in URI or am i missing something? I really feel that query_form() should handle multiple values with the same key, but giving the lack of response i got from Mr. Aas, i can't help but think i am missing something ... thanks :) (oh, and i am not ruling out the possibility that my message never reached Mr. Aas. - i just want to be sure before i bug him again.)
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: URI.pm bug or am i missing something?
by merlyn (Sage) on Apr 20, 2003 at 02:16 UTC | |
|
Re: URI.pm bug or am i missing something?
by Juerd (Abbot) on Apr 19, 2003 at 17:21 UTC | |
|
Re: URI.pm bug or am i missing something?
by demerphq (Chancellor) on Apr 19, 2003 at 17:56 UTC | |
by Anonymous Monk on Apr 20, 2003 at 10:07 UTC | |
by demerphq (Chancellor) on Apr 20, 2003 at 10:21 UTC | |
by merlyn (Sage) on Apr 20, 2003 at 16:11 UTC | |
|
Re: URI.pm bug or am i missing something?
by hossman (Prior) on Apr 20, 2003 at 06:10 UTC |