Mercurial > pub > Impl
diff Lib/IMPL/Web/QueryHandler/PageFormat.pm @ 162:39c8788eded5
corrected PATH_INFO handling
author | wizard |
---|---|
date | Wed, 29 Dec 2010 16:55:24 +0300 |
parents | 3f09584bf189 |
children | 4267a2ac3d46 |
line wrap: on
line diff
--- a/Lib/IMPL/Web/QueryHandler/PageFormat.pm Tue Dec 28 14:58:17 2010 +0300 +++ b/Lib/IMPL/Web/QueryHandler/PageFormat.pm Wed Dec 29 16:55:24 2010 +0300 @@ -20,7 +20,6 @@ public property templatesCharset => prop_all; public property templatesBase => prop_all; public property includes => prop_all | prop_list; - public property defaultTarget => prop_all; public property pathinfoPrefix => prop_all; public property cache => prop_all; public property preprocess => prop_all; @@ -48,27 +47,30 @@ my ($requestUri) = split /\?/, $ENV{REQUEST_URI}; my $pathInfo; - - if ( $requestUri eq $ENV{SCRIPT_NAME}.$ENV{PATH_INFO} ) { - # CGI with path info - $pathInfo = $ENV{PATH_INFO}; - } else { - die "REQUEST_URI: $requestUri\nPATH_INFO: $ENV{PATH_INFO}" unless $requestUri eq $ENV{PATH_INFO}; - } - my @root = (''); my @base; - if (my $rx = $this->pathinfoPrefix) { - $requestUri =~ s/^($rx)//; - push @root, grep $_, split /\//, $1 if $1; + if ( $requestUri eq $ENV{SCRIPT_NAME}.$ENV{PATH_INFO} ) { + # CGI with path info, for example + # /base/cgi-bin/myscript.cgi/path/info + # PATH_INFO will be /path/info + $pathInfo = $ENV{PATH_INFO}; + } else { + # usual url, for exmaple + # /base/script.cgi will have PATH_INFO /base/script.cgi + # /base/ will have PATH_INFO /base/index.cgi (if index.cgi is a DirectoryIndex) + $pathInfo = $ENV{PATH_INFO}; + + if (my $rx = $this->pathinfoPrefix) { + $requestUri =~ s/^($rx)//; + $pathInfo =~ s/^($rx)//; + push @root, grep $_, split /\//, $1 if $1; + } } - $pathInfo = $requestUri unless defined $pathInfo; - @base = grep $_, split /\//, ($pathInfo ? substr $requestUri,0, -length($pathInfo) : $requestUri); - local $ENV{PATH_INFO} = $pathInfo || $this->defaultTarget; + local $ENV{PATH_INFO} = $pathInfo; my @path = grep $_, split /\//, ($ENV{PATH_INFO} || '') or die new IMPL::Exception("PATH_INFO is empty and no defaultTarget specified" );