Skip Menu |

This queue is for tickets about the WWW-Mechanize-CGI CPAN distribution.

Report information
The Basics
Id: 16001
Status: resolved
Priority: 0/
Queue: WWW-Mechanize-CGI

People
Owner: Nobody in particular
Requestors: chris+rt [...] chrisdolan.net
Cc:
AdminCc:

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



Subject: Use cgi_application argument as SCRIPT_FILENAME
HTTP::Request::AsCGI hard-codes the $ENV{SCRIPT_FILENAME} to be '/'. WWW::Mechanize::CGI should override this to be the absolute path passed to cgi_application(), if applicable. Otherwise, CGI applications which make use of $ENV{SCRIPT_FILENAME} will be wrong. -- Chris
From: cdolan [...] cpan.org
Attached is a quick-and-dirty patch to implement $ENV{SCRIPT_FILENAME} -- Chris
diff -ur WWW-Mechanize-CGI-0.2-orig/lib/WWW/Mechanize/CGI.pm WWW-Mechanize-CGI-0.2/lib/WWW/Mechanize/CGI.pm --- WWW-Mechanize-CGI-0.2-orig/lib/WWW/Mechanize/CGI.pm 2005-11-02 15:02:56.000000000 -0600 +++ WWW-Mechanize-CGI-0.2/lib/WWW/Mechanize/CGI.pm 2005-11-21 08:23:08.000000000 -0600 @@ -17,6 +17,7 @@ if ( @_ ) { $self->{cgi} = shift; + $self->{cgiapp} = undef; } return $self->{cgi}; @@ -52,6 +53,7 @@ }; $self->cgi($cgi); + $self->{cgiapp} = $application; } sub fork { @@ -99,7 +101,15 @@ $c->setup; - eval { $self->cgi->() }; + my $fn = $self->{cgiapp} ? $self->{cgiapp} : $ENV{SCRIPT_FILENAME}; + { + local $ENV{SCRIPT_FILENAME}; + if (defined $fn) + { + $ENV{SCRIPT_FILENAME} = $fn; + } + eval {$self->cgi->() }; + } $c->restore;
[CLOTHO - Mon Nov 21 09:37:58 2005]: Show quoted text
> Attached is a quick-and-dirty patch to implement $ENV{SCRIPT_FILENAME} > -- Chris
Thanks for the report. A fix has been committed in trunk [1] that sets SCRIPT_FILENAME. [1] http://dev.catalyst.perl.org/repos/Catalyst/trunk/WWW-Mechanize-CGI/ -- Christian Hansen <ch@ngmedia.com>