From 0f7240c4441b085dd9f46a326abe19e6b5a77ed5 Mon Sep 17 00:00:00 2001 From: Kevin Scaldeferri Date: Mon, 10 Jul 2006 20:27:33 +0000 Subject: [PATCH] fix problem with CGI.pm and SSIs where url() doesn't work as documented --- blosxom.cgi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 -- 2.39.2