You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Honza Pazdziora <ad...@informatics.muni.cz> on 2000/06/05 14:08:40 UTC
Location makes redirect and confuses CGI::url
Hello,
this (longer) post deals with DirectoryIndex expansion,
Apache::PerlRun (Registry gives the same) and CGI's url('-relative' => 1)
method. The versions are 1.24, 2.68, 1.3.11 and 5.6.0+patches upto the
end of May. In the end, there is a proposed patch for CGI.pm, but as I'm
not sure if the behaviour is a bug or feature of mod_perl, I'm sending it
to modperl@apache.org as well, for comments.
This config
<LocationMatch ^/testing/(index\.pl)?$>
SetHandler perl-script
PerlSetVar PerlRunOnce On
PerlSendHeader On
PerlHandler Apache::PerlRun
</LocationMatch>
and request for https://server/testing/ leads to redirect, where the
interesting values (printed via %ENV) are
PATH_INFO=/
PATH_TRANSLATED=/www/
REDIRECT_PATH_INFO=/
REDIRECT_PATH_TRANSLATED=/www/
REDIRECT_REQUEST_URI=/testing/
REDIRECT_SCRIPT_FILENAME=/www/testing
REDIRECT_SCRIPT_NAME=/testing
REDIRECT_URL=/testing/
REQUEST_URI=/testing/
SCRIPT_FILENAME=/www/testing/index.pl
SCRIPT_NAME=/testing/index.pl
This confuses CGI.pm, because $q->url('-relative' => 1) returns
'testing', not '' as would be expected.
If I change the config to be
<LocationMatch ^/testing/index\.pl$>
SetHandler perl-script
PerlSetVar PerlRunOnce On
PerlSendHeader On
PerlHandler Apache::PerlRun
</LocationMatch>
the redirect seems to be much less aggresive and the values are
REDIRECT_URL=/testing/
REQUEST_URI=/testing/
SCRIPT_FILENAME=/www/testing/index.pl
SCRIPT_NAME=/testing/index.pl
There is no PATH_INFO value here, as well. And the PATH_INFO being
set in the previous case is the cause of the trouble. I believe that
the following patch fixes the problem -- from '/testing/', even if
the path_info is '/', the relative address still needs to stay '',
not 'testing', otherwise '/testing/testing' is achieved in the link.
--- CGI.pm.orig Mon Jun 5 14:04:12 2000
+++ CGI.pm Mon Jun 5 14:04:48 2000
@@ -2183,6 +2183,7 @@
# and path
if (exists($ENV{PATH_INFO})) {
my $decoded_path = unescape($ENV{PATH_INFO});
+ $decoded_path =~ s!^/!!;
substr($script_name,$index) = '' if ($index = rindex($script_name,$decoded_path)) >= 0;
}
} else {
Comments are gladly welcome.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
.project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
------------------------------------------------------------------------