diff options
author | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2011-07-09 08:56:13 +0100 |
---|---|---|
committer | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2011-07-09 08:56:13 +0100 |
commit | 90a3c601bbd1155d51dabb2c14501e3684ab4e5e (patch) | |
tree | dd52cba1ced0723244e4ea325015f051c8781783 /cpan | |
parent | 5fd1b70e236528a93d33ba08a5002331d4715567 (diff) | |
download | perl-90a3c601bbd1155d51dabb2c14501e3684ab4e5e.tar.gz |
Update CGI to CPAN version 3.55
[DELTA]
Version 3.55 June 3rd, 2011
[THINGS THAT MAY BREAK YOUR CODE]
url() was fixed to return "PATH_INFO" when it is explicitly requested
with either the path=>1 or path_info=>1 flag.
If your code is running under mod_rewrite (or compatible) and you are calling self_url() or
you are calling url() and passing path_info=>1, These methods will actually be
returning PATH_INFO now, as you have explicitly requested, or has self_url()
has requested on your behalf.
The PATH_INFO has been omitted in such URLs since the issue was introduced
in the 3.12 release in December, 2005.
This bug is so old your application may have come to depend on it or
workaround it. Check for application before upgrading to this release.
Examples of affected method calls:
$q->url(-absolute => 1, -query => 1, -path_info => 1 )
$q->url(-path=>1)
$q->url(-full=>1,-path=>1)
$q->url(-rewrite=>1,-path=>1)
$q->self_url();
Diffstat (limited to 'cpan')
-rw-r--r-- | cpan/CGI/Changes | 26 | ||||
-rw-r--r-- | cpan/CGI/lib/CGI.pm | 7 | ||||
-rw-r--r-- | cpan/CGI/t/url.t | 52 |
3 files changed, 78 insertions, 7 deletions
diff --git a/cpan/CGI/Changes b/cpan/CGI/Changes index 95c43e5eac..7c1b734fa6 100644 --- a/cpan/CGI/Changes +++ b/cpan/CGI/Changes @@ -1,3 +1,29 @@ + +Version 3.55 June 3rd, 2011 + + [THINGS THAT MAY BREAK YOUR CODE] + url() was fixed to return "PATH_INFO" when it is explicitly requested + with either the path=>1 or path_info=>1 flag. + + If your code is running under mod_rewrite (or compatible) and you are calling self_url() or + you are calling url() and passing path_info=>1, These methods will actually be + returning PATH_INFO now, as you have explicitly requested, or has self_url() + has requested on your behalf. + + The PATH_INFO has been omitted in such URLs since the issue was introduced + in the 3.12 release in December, 2005. + + This bug is so old your application may have come to depend on it or + workaround it. Check for application before upgrading to this release. + + Examples of affected method calls: + + $q->url(-absolute => 1, -query => 1, -path_info => 1 ) + $q->url(-path=>1) + $q->url(-full=>1,-path=>1) + $q->url(-rewrite=>1,-path=>1) + $q->self_url(); + Version 3.54, Apr 28, 2011 No code changes diff --git a/cpan/CGI/lib/CGI.pm b/cpan/CGI/lib/CGI.pm index 876ba27683..1d2ed8bc10 100644 --- a/cpan/CGI/lib/CGI.pm +++ b/cpan/CGI/lib/CGI.pm @@ -20,7 +20,7 @@ use Carp 'croak'; # The revision is no longer being updated since moving to git. $CGI::revision = '$Id: CGI.pm,v 1.266 2009/07/30 16:32:34 lstein Exp $'; -$CGI::VERSION='3.54'; +$CGI::VERSION='3.55'; # HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES. # UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING. @@ -2856,7 +2856,6 @@ sub url { my $query_str = $self->query_string; my $rewrite_in_use = $request_uri && $request_uri !~ /^\Q$script_name/; - undef $path if $rewrite_in_use && $rewrite; # path not valid when rewriting active my $uri = $rewrite && $request_uri ? $request_uri : $script_name; $uri =~ s/\?.*$//s; # remove query string @@ -5653,9 +5652,7 @@ If Apache's mod_rewrite is turned on, then the script name and path info probably won't match the request that the user sent. Set -rewrite=>1 (default) to return URLs that match what the user sent (the original request URI). Set -rewrite=>0 to return URLs that match -the URL after mod_rewrite's rules have run. Because the additional -path information only makes sense in the context of the rewritten URL, --rewrite is set to false when you request path info in the URL. +the URL after mod_rewrite's rules have run. =back diff --git a/cpan/CGI/t/url.t b/cpan/CGI/t/url.t index 16e20b6fc1..9af1c0c055 100644 --- a/cpan/CGI/t/url.t +++ b/cpan/CGI/t/url.t @@ -1,9 +1,10 @@ use strict; use warnings; -use Test::More tests => 4; # last test to print +use Test::More; + +use CGI ':all'; -use CGI qw/ :all /; $ENV{HTTP_X_FORWARDED_HOST} = 'proxy:8484'; $ENV{SERVER_PROTOCOL} = 'HTTP/1.0'; @@ -21,3 +22,50 @@ $ENV{HTTP_X_FORWARDED_HOST} = 'proxy:80'; is url() => 'http://proxy', 'url() with default port'; +subtest 'rewrite_interactions' => sub { + # Reference: RT#45019 + + local %ENV = ( + # These two are always set + 'SCRIPT_NAME' => '/real/cgi-bin/dispatch.cgi', + 'SCRIPT_FILENAME' => '/home/mark/real/path/cgi-bin/dispatch.cgi', + + # These two are added by mod_rewrite Ref: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html + + 'SCRIPT_URL' => '/real/path/info', + 'SCRIPT_URI' => 'http://example.com/real/path/info', + + 'PATH_INFO' => '/path/info', + 'REQUEST_URI' => '/real/path/info', + 'HTTP_HOST' => 'example.com' + ); + + my $q = CGI->new; + + is( + $q->url( -absolute => 1, -query => 1, -path_info => 1 ), + '/real/path/info', + '$q->url( -absolute => 1, -query => 1, -path_info => 1 ) should return complete path, even when mod_rewrite is detected.' + ); + is( $q->url(), 'http://example.com/real', '$q->url(), with rewriting detected' ); + is( $q->url(-full=>1), 'http://example.com/real', '$q->url(-full=>1), with rewriting detected' ); + is( $q->url(-path=>1), 'http://example.com/real/path/info', '$q->url(-path=>1), with rewriting detected' ); + is( $q->url(-path=>0), 'http://example.com/real', '$q->url(-path=>0), with rewriting detected' ); + is( $q->url(-full=>1,-path=>1), 'http://example.com/real/path/info', '$q->url(-full=>1,-path=>1), with rewriting detected' ); + is( $q->url(-rewrite=>1,-path=>0), 'http://example.com/real', '$q->url(-rewrite=>1,-path=>0), with rewriting detected' ); + is( $q->url(-rewrite=>1), 'http://example.com/real', + '$q->url(-rewrite=>1), with rewriting detected' ); + is( $q->url(-rewrite=>0), 'http://example.com/real/cgi-bin/dispatch.cgi', + '$q->url(-rewrite=>0), with rewriting detected' ); + is( $q->url(-rewrite=>0,-path=>1), 'http://example.com/real/cgi-bin/dispatch.cgi/path/info', + '$q->url(-rewrite=>0,-path=>1), with rewriting detected' ); + is( $q->url(-rewrite=>1,-path=>1), 'http://example.com/real/path/info', + '$q->url(-rewrite=>1,-path=>1), with rewriting detected' ); + is( $q->url(-rewrite=>0,-path=>0), 'http://example.com/real/cgi-bin/dispatch.cgi', + '$q->url(-rewrite=>0,-path=>1), with rewriting detected' ); +}; + + +done_testing(); + + |