Skip Menu |

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

Report information
The Basics
Id: 6180
Status: resolved
Worked: 15 min
Priority: 0/
Queue: CGI-Lite

People
Owner: HOUSTON [...] cpan.org
Requestors: qef [...] ungwe.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 2.02
Fixed in: 2.03



Subject: Fix for uninitialized value warning
Hi Smylers, When CGI::Lite is used to parse QUERY_STRING, with list context like this: my %cgi = CGI::Lite->parse_form_data; I get this warning when $ENV{QUERY_STRING} is empty: Use of uninitialized value in hash dereference at /usr/share/perl5/CGI/Lite.pm line 671. The attached patch fixes it, and will also avoid an unnecessary method call and string eval for this common case. qef
diff -ur CGI-Lite-2.02.orig/Lite.pm CGI-Lite-2.02/Lite.pm --- CGI-Lite-2.02.orig/Lite.pm 2003-08-19 19:53:08.000000000 +0100 +++ CGI-Lite-2.02/Lite.pm 2004-05-01 14:29:40.000000000 +0100 @@ -665,6 +665,7 @@ if ($request_method =~ /^(get|head)$/i) { $query_string = $ENV{QUERY_STRING}; + return unless $query_string; $self->_decode_url_encoded_data (\$query_string, 'form'); return wantarray ?
Hi qef, Thanks for the bug report and the associated patch. The warning that you get is because of the combination of no query string and the fact that you are calling parse_form_data as a class method rather than an object method. When an object is instantiated it gets the $self->{web_data} hashref created and that, albeit empty, is what is returned to the user if they call the object method. eg: my $q = CGI::Lite->new (); my %params = $q->parse_form_data; There is no warning generated and %params is () as I would expect. I'll do some further testing with your patch to make sure that there are no unintended consequences. If it all seems benign I see no reason not to include it. I'd still recommend using parse_form_data as an object method, however. Pete On Sat May 01 09:35:18 2004, guest wrote: Show quoted text
> Hi Smylers, > > When CGI::Lite is used to parse QUERY_STRING, with list context like > this: > > my %cgi = CGI::Lite->parse_form_data; > > I get this warning when $ENV{QUERY_STRING} is empty: > > Use of uninitialized value in hash dereference at > /usr/share/perl5/CGI/Lite.pm line 671. > > The attached patch fixes it, and will also avoid an unnecessary method > call and string eval for this common case. > > qef
This patch has been applied in 2.03. Please test and confirm that this has solved this bug for you. Thanks, Pete
No further reports of problems with this. Marking as solved.