URI doesn"t accept a semi-colon as query parameter separator
URI doesn"t accept a semi-colon as query parameter separator
am 24.11.2004 14:20:04 von Brian
Hi All,
NB: after composing this email, I checked URI's RT queue and noticed "Query
separator is hard-coded to be '&'" [1] -- which is the same issue. Maybe
it's important to revisit it.
I was testing an app at the command line which does some query and URL
manipulation. At one point, I pass the URL as generated from CGI.pm, which
happens to use a semi-colon (rather than an ampersand) as the query
parameter separator. Once I tried to access the params from the hash URI
returns from query_form(), I noticed that there was only 1 param instead of
the many more I was expecting.
Here's some sample code to reproduce the error.
use strict;
use warnings;
use CGI;
use URI;
use Data::Dumper;
my $query = CGI->new( { a => '1', b => '2' } );
my $url = $query->url( -query => 1 );
my $uri = URI->new( $url );
my %params = $uri->query_form;
print Dumper \$url;
print Dumper \%params;
__END__
$VAR1 = \'http://localhost/t.pl?a=1;b=2';
$VAR1 = {
'a' => '1;b=2'
};
One not so great workaround is to set:
$CGI::USE_PARAM_SEMICOLONS = 0;
....which will force CGI.pm to use ampersands. The above program with that
line added gives me:
$VAR1 = \'http://localhost/t.pl?a=1&b=2';
$VAR1 = {
'a' => '1',
'b' => '2'
};
-Brian
[1] http://rt.cpan.org/NoAuth/Bug.html?id=27
http://www.gordano.com - Messaging for educators.
Re: URI doesn"t accept a semi-colon as query parameter separator
am 24.11.2004 15:19:48 von tdb01r
----- Original Message -----
From: "Brian Cassidy"
> $CGI::USE_PARAM_SEMICOLONS = 0;
use CGI qw/-oldstyle_urls/;
But I've experienced problems with that class global under mod_perl, leading
to unpredictable behaviour.
Given 99.99999% of Web sites use ampersands it's kinda annoying CGI defaults
to semi-colons (and more annoying that CGI & URI don't play nice together).
All the best,
Tim.
Re: URI doesn"t accept a semi-colon as query parameter separator
am 24.11.2004 15:55:01 von gisle
"Brian Cassidy" writes:
>
> I was testing an app at the command line which does some query and URL
> manipulation. At one point, I pass the URL as generated from CGI.pm, which
> happens to use a semi-colon (rather than an ampersand) as the query
> parameter separator. Once I tried to access the params from the hash URI
> returns from query_form(), I noticed that there was only 1 param instead of
> the many more I was expecting.
Is using the URI::Semi class workable for you? If not, why?
http://www.rosat.mpe-garching.mpg.de/mailing-lists/libwww-pe rl/2002-09/msg00022.html
RE: URI doesn"t accept a semi-colon as query parameter separator
am 16.12.2004 14:26:41 von Brian
Hello,
> -----Original Message-----
> Is using the URI::Semi class workable for you? If not, why?
>
> http://www.rosat.mpe-garching.mpg.de/mailing-lists/libwww-pe rl/2002-
> 09/msg00022.html
Sorry I haven't replied sooner! I've opted to force CGI.pm to use
ampersands, thus averting the issue.
Thanks for your patience and time.
-Brian
http://www.gordano.com - Messaging for educators.