From: Nicholas Clark Date: Sun, 7 Sep 2008 08:46:13 +0000 (+0000) Subject: Upgrade to CGI.pm 3.41 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e1c704842521886e4ceb1683d94fbb79433cd841;p=p5sagit%2Fp5-mst-13.2.git Upgrade to CGI.pm 3.41 Local change 34208, 34278 remain. p4raw-id: //depot/perl@34302 --- diff --git a/lib/CGI.pm b/lib/CGI.pm index c4ee7bf..5b3d3d2 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.257 2008/08/06 14:01:06 lstein Exp $'; -$CGI::VERSION='3.40_01'; +$CGI::revision = '$Id: CGI.pm,v 1.259 2008/08/20 13:45:25 lstein Exp $'; +$CGI::VERSION='3.41_01'; # Changes 34208, 34278 # HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES. # UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING. @@ -2720,8 +2720,9 @@ sub url { undef $path if $rewrite_in_use && $rewrite; # path not valid when rewriting active my $uri = $rewrite && $request_uri ? $request_uri : $script_name; - $uri =~ s/\?.*$//; # remove query string - $uri =~ s/\Q$path\E$// if defined $path; # remove path + $uri =~ s/\?.*$//s; # remove query string + $uri =~ s/\Q$ENV{PATH_INFO}\E$// if defined $ENV{PATH_INFO}; +# $uri =~ s/\Q$path\E$// if defined $path; # remove path if ($full) { my $protocol = $self->protocol(); @@ -3709,6 +3710,7 @@ END_OF_AUTOLOAD ################### Fh -- lightweight filehandle ############### package Fh; + use overload '""' => \&asString, 'cmp' => \&compare, @@ -3769,6 +3771,14 @@ sub new { } END_OF_FUNC +'handle' => <<'END_OF_FUNC', +sub handle { + my $self = shift; + eval "require IO::Handle" unless IO::Handle->can('new_from_fd'); + return IO::Handle->new_from_fd(fileno $self,"<"); +} +END_OF_FUNC + ); END_OF_AUTOLOAD @@ -6074,24 +6084,27 @@ filehandle at all, but a string. To be safe, use the I function (new in version 2.47). When called with the name of an upload field, I returns a -filehandle, or undef if the parameter is not a valid filehandle. +filehandle-like object, or undef if the parameter is not a valid +filehandle. $fh = upload('uploaded_file'); while (<$fh>) { print; } -In an list context, upload() will return an array of filehandles. +In a list context, upload() will return an array of filehandles. This makes it possible to create forms that use the same name for 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: +The lightweight filehandle returned by CGI.pm is not compatible with +IO::Handle; for example, it does not have read() or getline() +functions, but instead must be manipulated using read($fh) or +<$fh>. To get a compatible IO::Handle object, call the handle's +handle() method: - seek($fh,0,0); # reset postion to beginning of file. + my $real_io_handle = upload('uploaded_file')->handle; When a file is uploaded the browser usually sends along some information along with it in the format of headers. The information diff --git a/lib/CGI/Changes b/lib/CGI/Changes index 9acc4d3..e4f05fc 100644 --- a/lib/CGI/Changes +++ b/lib/CGI/Changes @@ -1,3 +1,38 @@ + Version 3.41 + 1. Fix url() returning incorrect path when query string contains escaped newline. + 2. Added additional windows temporary directories and environment variables, courtesy patch from Renee Baecker + 3. Added a handle() method to the lightweight upload + filehandles. This method returns a real IO::Handle object. + 4. Added patch from Tony Vanlingen to fix deep recursion warnings in CGI::Pretty. + + Version 3.40 + 1. Fixed CGI::Fast docs to eliminate references to a "special" + version of Perl. + 2. Makefile.PL now depends on FCGI so that CGI::Fast installs properly. + 3. Fix script_name() call from Stephane Chazelas. + + Version 3.39 + 1. Fixed regression in "exists" function when using tied interface to CGI via $q->Vars. + + Version 3.38 + 1. Fix annoying warning in http://rt.cpan.org/Ticket/Display.html?id=34551 + 2. Added nobr() function http://rt.cpan.org/Ticket/Display.html?id=35377 + 3. popup_menu() allows multiple items to be selected by default, satisfying + http://rt.cpan.org/Ticket/Display.html?id=35376 + 4. Patch from Renee Backer to avoid doubled headers. + 5. Fixed documentation bug that describes what happens when a + parameter is empty (e.g. "?test1="). + 6. Fixed minor warning described at http://rt.cpan.org/Public/Bug/Display.html?id=36435 + 7. Fixed overlap of attribute and parameter space described in http://rt.perl.org/rt3//Ticket/Display.html?id=24294 + + Version 3.37 + 1. Fix pragmas so that they persist over modperl invocations (e.g. RT 34761) + 2. Fixed handling of chunked multipart uploads; thanks to Michael Bernhardt + who reported and fixed the problem. + + Version 3.36 + 1. Fix CGI::Cookie to support cookies that are separated by "," instead of ";". + Version 3.35 1. Resync with bleadperl, primarily fixing a bug in parsing semicolons in uploaded filenames.