Subject: | [PATCH] Calling the upload method without argument leads to an error |
Calling the upload method without argument leads to an error - the
method returns no reply. Here is a patch attached to fix the issue.
Subject: | CGI_upload.patch |
diff -ru CGI.pm-3.43/CGI.pm CGI.pm-new/CGI.pm
--- CGI.pm-3.43/CGI.pm Wed Feb 11 18:56:37 2009
+++ CGI.pm-new/CGI.pm Thu Apr 16 08:53:24 2009
@@ -3640,7 +3640,7 @@
'upload' =><<'END_OF_FUNC',
sub upload {
my($self,$param_name) = self_or_default(@_);
- my @param = grep {ref($_) && defined(fileno($_))} $self->param($param_name);
+ my @param = grep {ref($_) && defined(fileno($_))} map { $self->param($_) } $param_name || $self->param();
return unless @param;
return wantarray ? @param : $param[0];
}
diff -ru CGI.pm-3.43/t/upload.t CGI.pm-new/t/upload.t
--- CGI.pm-3.43/t/upload.t Mon Sep 8 16:52:59 2008
+++ CGI.pm-new/t/upload.t Thu Apr 16 09:02:19 2009
@@ -96,6 +96,17 @@
ok( defined $q->upload('100;100_gif') , 'upload_basic_3' );
ok( defined $q->upload('300x300_gif') , 'upload_basic_4' );
+
+{
+ my @upload = $q->upload();
+ my %upload = map { $_ => $_ } @upload;
+ ok( exists $upload{'does_not_exist.gif'}, 'upload_basic_all_2' );
+ ok( exists $upload{'100;100.gif'} , 'upload_basic_all_3' );
+ ok( exists $upload{'300x300.gif'} , 'upload_basic_all_4' );
+
+}
+
+
{
my $test = "file handles have expected length for multi-valued field. ";
my ($goodbye_fh,$hello_fh) = $q->upload('hello_world');