Subject: | CGI-3.40 url() method still has incorrect behavior with URL-encoded characters |
Date: | Thu, 14 Aug 2008 08:55:20 -0700 |
To: | bug-CGI.pm [...] rt.cpan.org |
From: | Don Maszle <dmaszle [...] mendelbio.com> |
This has been reported in early 3.x versions (ref: #18752), but has yet
to be addressed in the recent 3.40 release.
On our SunOS 5.9 sparc Sun-Fire-V890 using Perl 5.8.5. It appears that
(at least) the -query switch of url() is not handled properly if the URI
contains encoded characters. The program at the end can be used to
demonstrate.
When called with
http://localhost/cgi-bin/url.cgi?q=abc%0Adef
url() incorrectly returns *all* URLs with the query string attached.
When called with
http://localhost/cgi-bin/url.cgi?q=abc%0Adef
url() correctly returns URLs with the query string attached
only when the attribute -query=>1 is set.
Show quoted text
__________________________________________________________________________
#!/usr/bin/perl -w
use CGI;
my $Q = new CGI;
print $Q->header, $Q->start_html;
print "<h1>CGI::url() Test</h1>\n";
print "<br>Apache :<b>'".$ENV{REQUEST_URI}."'</b>\n";
print "<br>No Args:'".$Q->url."'\n";
print "<br>rel1, query0: ".$Q->url(-relative=>1,-query=>0)."\n";
print "<form action=\x22".$Q->url(-relative=>1,-query=>0)."\x22><input type=submit></form>";
print "<h2>Using -key Arguments</h2>\n";
print "Abs : 0:'".$Q->url(-absolute=>0)."'\n";
print "<br>Abs : 1:'".$Q->url(-absolute=>1)."'\n";
print "<br>";
print "<br>Query: 0, Abs : 0:'".$Q->url(-absolute=>0,-query=>0)."'\n";
print "<br>Query: 0, Abs : 1:'".$Q->url(-absolute=>1,-query=>0)."'\n";
print "<br>";
print "<br>Query: 1, Abs : 0:'".$Q->url(-absolute=>0,-query=>1)."'\n";
print "<br>Query: 1, Abs : 1:'".$Q->url(-absolute=>1,-query=>1)."'\n";
print "<br>";
print "<br>Rel : 0:'".$Q->url(-relative=>0)."'\n";
print "<br>Rel : 1:'".$Q->url(-relative=>1)."'\n";
print "<br>";
print "<br>Query: 0, Rel : 0:'".$Q->url(-relative=>0,-query=>0)."'\n";
print "<br>Query: 0, Rel : 1:'".$Q->url(-relative=>1,-query=>0)."'\n";
print "<br>";
print "<br>Query: 1, Rel : 0:'".$Q->url(-relative=>0,-query=>1)."'\n";
print "<br>Query: 1, Rel : 1:'".$Q->url(-relative=>1,-query=>1)."'\n";
print "<br>";
print "<br>Full: 0:'".$Q->url(-full=>0)."'\n";
print "<br>Full: 1:'".$Q->url(-full=>1)."'\n";
print "<br>";
print "<br>Path: 0:'".$Q->url(-path_info=>0)."'\n";
print "<br>Path: 1:'".$Q->url(-path_info=>1)."'\n";
print "<br>";
print "<br>Qury: 0:'".$Q->url(-query=>0)."'\n";
print "<br>Qury: 1:'".$Q->url(-query=>1)."'\n";
print "<br>";
print "<br>Base: 0:'".$Q->url(-base=>0)."'\n";
print "<br>Base: 1:'".$Q->url(-base=>1)."'\n";
print "<br>";
print "<br>Rewr: 0:'".$Q->url(-rewrite=>0)."'\n";
print "<br>Rewr: 1:'".$Q->url(-rewrite=>1)."'\n";
print "<br>";
print $Q->end_html;