[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] Warning when $ENV{PATH_INFO} is undefined. [Patch]


Hi all.

I'm experiencing a (minor) problem that arises when, once you've set:

$webapp->mode_param( path_info => 1 ); #2, 3 etc.

(to let C::A retrieve the requested run mode from $ENV{PATH_INFO},) you
run your webapp by passing no extra path information to your cgi driver,
like this:

http://localhost/cgi-bin/webapp.cgi

Though not advised (since it can subtly break your relative links,) this
should be perfectly legal according to the docs, and actually
CGI::Application gracefully selects the default run mode, as expected.

The (only) problem is that this situation generates a couple of warnings
(which end up in your Apache's error.log,) because $ENV{PATH_INFO} is
undefined but CGI::Application nevertheless tries to extract the run
mode from it.

Here are the log entries from my Winzozz developing box:

[error] [client 127.0.0.1] Use of uninitialized value in substitution
(s///) at c:/Perl/site/lib/CGI/Application.pm line 1446.\n
[error] [client 127.0.0.1] Use of uninitialized value in split at
c:/Perl/site/lib/CGI/Application.pm line 1449.\n

I don't even know if it is a real issue or it's a known problem or even
a desirable feature: I mean, I'm not expert enough about C::A to claim
anything about the way it should work. I just have a vague feeling, so
to say, that this should be fixed.
It's up to you (Jesse, Mark and all of the others) to decide whether to
fix this or leave it as is, or even to prevent such way to call the
instance script when path_info is set (though preventing things has an
unbearable Java stench.)

Anyway here is a patch (against CGI::Application 3.31).
It has been tested and it seems to me the most obvious and cleanest
solution.

Thanks to all of the contributors for their invaluable work!

Ciao,
Emanuele Zeppieri.

# $Id: Application.pm,v 1.42 2004/05/12 17:04:08 jesse Exp $
------------------------------------------------------------

--- Application.pm.original     Mon Sep 27 03:31:28 2004
+++ Application.pm      Fri Feb 18 05:18:06 2005
@@ -1437,7 +1437,7 @@
                %p = @_;
                $mode_param = $p{param};

-               if ($p{path_info}) {
+               if ($p{path_info} && $ENV{PATH_INFO}) {
                        my $pi = $ENV{PATH_INFO};
                        # computer scientists like to start counting
from zero.

                        my $idx = $p{path_info} - 1;


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.