From: Steve Peters Date: Tue, 8 May 2007 15:09:20 +0000 (+0000) Subject: Upgrade to CGI.pm-3.29 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=681699b9e2d2fac17ec7bfd8021c0e489fe3e243;p=p5sagit%2Fp5-mst-13.2.git Upgrade to CGI.pm-3.29 p4raw-id: //depot/perl@31170 --- diff --git a/lib/CGI.pm b/lib/CGI.pm index a65bed2..0d5ef00 100644 --- a/lib/CGI.pm +++ b/lib/CGI.pm @@ -18,8 +18,8 @@ use Carp 'croak'; # The most recent version and complete docs are available at: # http://stein.cshl.org/WWW/software/CGI/ -$CGI::revision = '$Id: CGI.pm,v 1.229 2007/03/29 15:35:40 lstein Exp $'; -$CGI::VERSION='3.28'; +$CGI::revision = '$Id: CGI.pm,v 1.234 2007/04/16 16:58:46 lstein Exp $'; +$CGI::VERSION='3.29'; # HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES. # UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING. @@ -119,6 +119,7 @@ sub initialize_globals { undef %EXPORT; undef $QUERY_CHARSET; undef %QUERY_FIELDNAMES; + undef %QUERY_TMPFILES; # prevent complaints by mod_perl 1; @@ -506,12 +507,20 @@ sub init { # ourselves from the original query (which may be gone # if it was read from STDIN originally.) if (defined(@QUERY_PARAM) && !defined($initializer)) { - foreach (@QUERY_PARAM) { - $self->param('-name'=>$_,'-value'=>$QUERY_PARAM{$_}); - } - $self->charset($QUERY_CHARSET); - $self->{'.fieldnames'} = {%QUERY_FIELDNAMES}; - return; + for my $name (@QUERY_PARAM) { + my $val = $QUERY_PARAM{$name}; # always an arrayref; + $self->param('-name'=>$name,'-value'=> $val); + if (defined $val and ref $val eq 'ARRAY') { + for my $fh (grep {defined(fileno($_))} @$val) { + seek($fh,0,0); # reset the filehandle. + } + + } + } + $self->charset($QUERY_CHARSET); + $self->{'.fieldnames'} = {%QUERY_FIELDNAMES}; + $self->{'.tmpfiles'} = {%QUERY_TMPFILES}; + return; } $meth=$ENV{'REQUEST_METHOD'} if defined($ENV{'REQUEST_METHOD'}); @@ -597,21 +606,6 @@ sub init { } last METHOD; } - - if (defined($fh) && ($fh ne '')) { - while (<$fh>) { - chomp; - last if /^=/; - push(@lines,$_); - } - # massage back into standard format - if ("@lines" =~ /=/) { - $query_string=join("&",@lines); - } else { - $query_string=join("+",@lines); - } - last METHOD; - } if (defined($fh) && ($fh ne '')) { while (<$fh>) { @@ -762,6 +756,7 @@ sub save_request { } $QUERY_CHARSET = $self->charset; %QUERY_FIELDNAMES = %{$self->{'.fieldnames'}}; + %QUERY_TMPFILES = %{ $self->{'.tmpfiles'} || {} }; } sub parse_params { @@ -4298,7 +4293,10 @@ HTML "standards". $query = new CGI; This will parse the input (from both POST and GET methods) and store -it into a perl5 object called $query. +it into a perl5 object called $query. + +Any filehandles from file uploads will have their position reset to +the beginning of the file. =head2 CREATING A NEW QUERY OBJECT FROM AN INPUT FILE @@ -6002,6 +6000,12 @@ multiple upload fields. This is the recommended idiom. +For robust code, consider reseting the file handle position to beginning of the +file. Inside of larger frameworks, other code may have already used the query +object and changed the filehandle postion: + + seek($fh,0,0); # reset postion to beginning of file. + When a file is uploaded the browser usually sends along some information along with it in the format of headers. The information usually includes the MIME content type. Future browsers may send diff --git a/lib/CGI/Changes b/lib/CGI/Changes index 03a44b1..c2f307a 100644 --- a/lib/CGI/Changes +++ b/lib/CGI/Changes @@ -1,3 +1,10 @@ + Version 3.29 + 1. The position of file handles is now reset to zero when CGI->new is called. + (Mark Stosberg) + 2. uploadInfo() now works across multiple object instances. Also, the first + tests for uploadInfo() were added as part of the fix. (CPAN bug 11895, with + contributions from drfrench and Mark Stosberg). + Version 3.28 1. Applied patch from Allen Day that makes Cookie parsing RFC2109 compliant (attribute/values can be separated by commas as well as semicolons). @@ -62,6 +69,15 @@ 2. Patch from Steve Peters to default the document type to match the charset. 3. Fixed param() so that param(-name=>'foo',-values=>[]) sets the parameter to empty list. + Version 3.17 Fri Feb 24 14:01:27 EST 2006 + 1. Added patch from Mike Hanafey which caused 0 arguments to CGI::Cookie->new() to + be treated as empty. + 2. Patch to CGI::Carp from Peter Whaite to fix the unfixable problem of CGI::Carp + not behaving correctly in an eval() context. + 3. CGI::Fast->new() calls CGI->_reset_globals to avoid contamination of one session + with another's variables. + 4. Fixed upload failure on files that contain semicolons in their names. + Version 3.16 Wed Feb 8 13:29:11 EST 2006 1. header() -charset option now works even when the MIME type is not "text". 2. Fixed documentation for cookie() function and fastCGI.