Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

(larryk) possible bug in CGI.pm - Re: Perl, Apache, Dr. Watson, and my scripts

by larryk (Friar)
on Aug 16, 2001 at 19:52 UTC ( [id://105416]=note: print w/replies, xml ) Need Help??


in reply to Perl, Apache, Dr. Watson, and my scripts

the error message refers to $param being undefined...

it looks like the parameter name is not defined and (in my version of CGI.pm at least) this looks like a problem...

# from CGI.pm sub parse_params { my($self,$tosplit) = @_; my(@pairs) = split(/[&;]/,$tosplit); my($param,$value); foreach (@pairs) { ($param,$value) = split('=',$_,2); $value = '' unless defined $value; $param = unescape($param); # this is where the situation goes unchecked... # CGI::Util::unescape returns undef if $param is undef # none the wiser and no error checking! $value = unescape($value); $self->add_parameter($param); push (@{$self->{$param}},$value); } }
so my guess is that you have a URL like:
http://your.site.here/cgi-bin/script.pl?param1=value1&=value2&param3=v +alue3
which is lacking "param2" and would cause the issue you are seeing. try adding...
next unless defined $param;
where I put the 3 line comment inside the parse_params sub

hope this helps

update: if this does turn out to be the problem you may want to check if the most recent version has the same problem - if so you can email the author(s) and let him/her/them know you have discovered a bug

   larryk                                          
perl -le "s,,reverse killer,e,y,rifle,lycra,,print"

Replies are listed 'Best First'.
print "true" unless $MrCromeDome ne "dumbass"
by MrCromeDome (Deacon) on Aug 16, 2001 at 20:17 UTC
    Yeah, that will always print true ;)

    It's pretty much the situation that you describe above. . . just a little bit different. Instead of this:

    http://cygnus/cgi-bin/view.cgi?document=12345678&=name
    I have this:
    http://cygnus/cgi-bin/view.cgi?document=12345678&&tab=name
    Note the &&. If I make it a single &, it seems to work fine. Seems like I made a pretty fatal typo there. I don't know if that indicates a problem with CGI or not (my guess is not), but I do know that things work fine without the second &.

    Thanks for your help :)
    MrCromeDome

      typo - yes
      fatal - shouldn't have been (IMHO)

      CGI.pm is basically doing
      #!/usr/bin/perl -w use strict; $_ = 'test1=1&&test3=3'; for ( split '&' ) { my($param,$value) = split '='; print "param='$param'\n"; print "value='$value'\n"; # and using $param even though it is undefined the 2nd time }
      You said that both versions of apache are the same but it looks like the two versions of CGI.pm are different - you can check ~ line 22 of CGI.pm for the version number.

      if they are the same then I'm stumped - otherwise you should probably upgrade to the newer one at least as it looks like it is handling malformed URLs properly (this type anyway).

         larryk                                          
      perl -le "s,,reverse killer,e,y,rifle,lycra,,print"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://105416]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found