From: Kevin Scaldeferri Date: Mon, 10 Jul 2006 20:27:33 +0000 (+0000) Subject: fix problem with CGI.pm and SSIs where url() doesn't work as documented X-Git-Tag: debian/2.1.2-2~124 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=0f7240c4441b085dd9f46a326abe19e6b5a77ed5;p=pkg%2Fblosxom.git fix problem with CGI.pm and SSIs where url() doesn't work as documented --- diff --git a/blosxom.cgi b/blosxom.cgi index 068b718..997fcc7 100755 --- a/blosxom.cgi +++ b/blosxom.cgi @@ -84,8 +84,17 @@ my $fh = new FileHandle; @num2month = sort { $month2num{$a} <=> $month2num{$b} } keys %month2num; # Use the stated preferred URL or figure it out automatically -$url ||= url(); -$url =~ s/^included:/http:/; # Fix for Server Side Includes (SSI) +$url ||= url(-path_info => 1); +$url =~ s/^included:/http:/ if $ENV{SERVER_PROTOCOL} eq 'INCLUDED'; + +# NOTE: Since v3.12, it looks as if CGI.pm misbehaves for SSIs and +# always appends path_info to the url. To fix this, we always +# request an url with path_info, and always remove it from the end of the +# string. +my $pi_len = length $ENV{PATH_INFO}; +my $might_be_pi = substr($url, -$pi_len); +substr($url, -length $ENV{PATH_INFO}) = '' if $might_be_pi eq $ENV{PATH_INFO}; + $url =~ s!/$!!; # Drop ending any / from dir settings