Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI CPAN distribution.

Report information
The Basics
Id: 89827
Status: resolved
Priority: 0/
Queue: CGI

People
Owner: Nobody in particular
Requestors: Sune.Karlsson [...] oru.se
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: url() does not behave as expected on IIS
Date: Tue, 29 Oct 2013 00:18:52 +0000
To: "bug-CGI.pm [...] rt.cpan.org" <bug-CGI.pm [...] rt.cpan.org>
From: Sune Karlsson <Sune.Karlsson [...] oru.se>
This problem occurs with IIS6 (Windows Server 2003), IIS7 (Windows 7 and Windows Server 2008) and different versions of Perl and CGI. The following script called as http://XXX/scripts/test.pl?t=t #---- use CGI; $q = new CGI; print $q->header(); print '<html>'; print "<p>Perl version: $^V\n"; print "<p>CGI version: $CGI::VERSION\n"; print '<p>self_url: ' . $q->self_url() . "\n"; print '<p>url: ' . $q->url() . "\n"; print '<p>url(-full=>1): ' . $q->url(-full=>1) . "\n"; print '<p>url(-relative=>1): ' . $q->url(-relative=>1) . "\n"; print '<p>url(-absolute=>1): ' . $q->url(-absolute=>1) . "\n"; print '<p>url(-path_info=>1): ' . $q->url(-path_info=>1) . "\n"; print '<p>url(-path_info=>1,-query=>1): ' . $q->url(-path_info=>1,-query=>1) . "\n"; print '<p>url(-base => 1): ' . $q->url(-base => 1) . "\n"; print '</html>'; #--- Returns Perl version: v5.16.3 CGI version: 3.63 self_url: http://XXX/scripts/test.pl?t=t url: http://XXX url(-full=>1): http://XXX url(-relative=>1): url(-absolute=>1): url(-path_info=>1): http://XXX/scripts/test.pl url(-path_info=>1,-query=>1): http://XXX/scripts/test.pl?t=t url(-base => 1): http://XXX while the documentation leads me to believe that url() and url(-full=>1) should return http://XXX/scripts/test.pl, url(-relative=>1) should return test.pl and url(-absolute=>1) should return /scripts/test.pl. If the script is called with additional path information, http://XXX/scripts/test.pl/test?t=t, it behaves as expected: Perl version: v5.16.3 CGI version: 3.63 self_url: http://XXX/scripts/test.pl/scripts/test.pl/test?t=t url: http://XXX/scripts/test.pl url(-full=>1): http://XXX/scripts/test.pl url(-relative=>1): test.pl url(-absolute=>1): /scripts/test.pl url(-path_info=>1): http://XXX/scripts/test.pl/scripts/test.pl/test url(-path_info=>1,-query=>1): http://XXX/scripts/test.pl/scripts/test.pl/test?t=t url(-base => 1): http://XXX /Sune -- Sune Karlsson Professor of Statistics Handelshögskolan/Örebro University School of Business Örebro University, SE-70182 Örebro, Sweden Phone +46 19 301257/301415 http://www.oru.se/hh/sune_karlsson http://econpapers.repec.org/RAS/pka1.htm
This issue has been copied to: https://github.com/leejo/CGI.pm/issues/126 please take all future correspondence there. This ticket will remain open but please do not reply here. This ticket will be closed when the github issue is dealt with.
After a bit of googling i believe this is a problem with IIS. Since in sub url CGI.pm does (and always has done): $uri =~ s/\Q$ENV{PATH_INFO}\E$// if defined $ENV{PATH_INFO}; PATH_INFO being the same as SCRIPT_NAME in certain configurations of IIS causes the SCRIPT_NAME to be substituted out of the uri and leads to an empty return value on -relative and -absolute. I have added a fix to prevent CGI.pm remove PATH_INFO if it is the same as SCRIPT_NAME. commit 44ab08c8397afd423c52da6c729d01818bf5d17e Author: Lee Johnson <lee@givengain.ch> Date: Fri Oct 17 17:19:04 2014 +0200 resolve #126 [rt.cpan.org #89827] - fix url PATH_INFO substitution logic to not remove PATH_INFO if it is the same as SCRIPT_NAME as some webservers (IIS) sometimes set PATH_INFO to the same value as SCRIPT_NAME Changes | 4 ++++ lib/CGI.pm | 8 +++++++- t/url.t | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-)