]> git.deb.at Git - pkg/blosxom.git/commitdiff
fix problem with CGI.pm and SSIs where url() doesn't work as documented
authorKevin Scaldeferri <kscaldef@users.sourceforge.net>
Mon, 10 Jul 2006 20:27:33 +0000 (20:27 +0000)
committerKevin Scaldeferri <kscaldef@users.sourceforge.net>
Mon, 10 Jul 2006 20:27:33 +0000 (20:27 +0000)
blosxom.cgi

index 068b7183d1afb9f85010de247d56f428670346e7..997fcc74a4a00fdc80eb0cd82265e8c64f850643 100755 (executable)
@@ -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