diff options
Diffstat (limited to 'cpan/CGI/t/url.t')
-rw-r--r-- | cpan/CGI/t/url.t | 52 |
1 files changed, 50 insertions, 2 deletions
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(); + + |