diff options
author | Lincoln Stein <lstein@genome.wi.mit.edu> | 1997-04-18 06:22:51 +1200 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1997-04-27 00:00:00 +1200 |
commit | 47e3cabda9bbdb8cfcaa856cd58b1452b57cb369 (patch) | |
tree | 1cf77e6db51619b0b478e1b16cf01d8736af4cbd | |
parent | 0dc443ab240d96700aca2fe15c6e555416114ee7 (diff) | |
download | perl-47e3cabda9bbdb8cfcaa856cd58b1452b57cb369.tar.gz |
Refresh CGI.pm to 2.35
-rw-r--r-- | lib/CGI.pm | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/lib/CGI.pm b/lib/CGI.pm index 92c875be60..2ae635ead2 100644 --- a/lib/CGI.pm +++ b/lib/CGI.pm @@ -28,8 +28,8 @@ $AUTOLOAD_DEBUG=0; # 3) print header(-nph=>1) $NPH=0; -$CGI::revision = '$Id: CGI.pm,v 2.34 1997/4/7 7:23 lstein Exp $'; -$CGI::VERSION='2.3402'; +$CGI::revision = '$Id: CGI.pm,v 2.35 1997/4/20 20:19 lstein Exp $'; +$CGI::VERSION='2.35'; # OVERRIDE THE OS HERE IF CGI.pm GUESSES WRONG # $OS = 'UNIX'; @@ -546,8 +546,6 @@ sub all_parameters { return @{$self->{'.parameters'}}; } - - #### Method as_string # # synonym for "dump" @@ -1018,6 +1016,7 @@ END_OF_FUNC # $xbase -> (optional) alternative base at some remote location (-xbase) # $target -> (optional) target window to load all links into (-target) # $script -> (option) Javascript code (-script) +# $no_script -> (option) Javascript <noscript> tag (-noscript) # $meta -> (optional) Meta information tags # @other -> (optional) any other named parameters you'd like to incorporate into # the <BODY> tag. @@ -1025,8 +1024,8 @@ END_OF_FUNC 'start_html' => <<'END_OF_FUNC', sub start_html { my($self,@p) = &self_or_default(@_); - my($title,$author,$base,$xbase,$script,$target,$meta,@other) = - $self->rearrange([TITLE,AUTHOR,BASE,XBASE,SCRIPT,TARGET,META],@p); + my($title,$author,$base,$xbase,$script,$noscript,$target,$meta,@other) = + $self->rearrange([TITLE,AUTHOR,BASE,XBASE,SCRIPT,NOSCRIPT,TARGET,META],@p); # strangely enough, the title needs to be escaped as HTML # while the author needs to be escaped as a URL @@ -1054,6 +1053,12 @@ $script </SCRIPT> END ; + push(@result,<<END) if $noscript; +<NOSCRIPT> +$noscript +</NOSCRIPT> +END + ; my($other) = @other ? " @other" : ''; push(@result,"</HEAD><BODY$other>"); return join("\n",@result); @@ -2327,6 +2332,7 @@ sub read_multipart { my(%header,$body); while (!$buffer->eof) { %header = $buffer->readHeader; + die "Malformed multipart POST\n" unless %header; # In beta1 it was "Content-disposition". In beta2 it's "Content-Disposition" # Sheesh. @@ -2465,7 +2471,6 @@ sub new { # Read the topmost (boundary) line plus the CRLF my($null) = ''; $length -= $interface->read_from_client($IN,\$null,length($boundary)+2,0); - } else { # otherwise we find it ourselves my($old); ($old,$/) = ($/,$CRLF); # read a CRLF-delimited line @@ -2494,12 +2499,15 @@ sub readHeader { my($self) = @_; my($end); my($ok) = 0; + my($bad) = 0; do { $self->fillBuffer($FILLUNIT); $ok++ if ($end = index($self->{BUFFER},"${CRLF}${CRLF}")) >= 0; $ok++ if $self->{BUFFER} eq ''; + $bad++ if !$ok && $self->{LENGTH} <= 0; $FILLUNIT *= 2 if length($self->{BUFFER}) >= $FILLUNIT; - } until $ok; + } until $ok || $bad; + return () if $bad; my($header) = substr($self->{BUFFER},0,$end+2); substr($self->{BUFFER},0,$end+4) = ''; @@ -2540,6 +2548,8 @@ sub read { # Find the boundary in the buffer (it may not be there). my $start = index($self->{BUFFER},$self->{BOUNDARY}); + # protect against malformed multipart POST operations + die "Malformed multipart POST\n" unless ($start >= 0) || ($self->{LENGTH} > 0); # If the boundary begins the data, then skip past it # and return undef. The +2 here is a fiendish plot to @@ -2595,7 +2605,7 @@ sub fillBuffer { $bytesToRead, $bufferLength); - # An apparent bug in the Netscape Commerce server causes the read() + # An apparent bug in the Apache server causes the read() # to return zero bytes repeatedly without blocking if the # remote user aborts during a file transfer. I don't know how # they manage this, but the workaround is to abort if we get @@ -2725,7 +2735,10 @@ The current version of CGI.pm is available at http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html ftp://ftp-genome.wi.mit.edu/pub/software/WWW/ -=head1 INSTALLATION: +=head1 INSTALLATION + +CGI is a part of the base Perl installation. However, you may need +to install a newer version someday. Therefore: To install this package, just change to the directory in which this file is found and type the following: @@ -3204,7 +3217,7 @@ There is no support for the HTTP-EQUIV type of <META> tag. This is because you can modify the HTTP header directly with the B<header()> method. -JAVASCRIPTING: The B<-script>, B<-onLoad> and B<-onUnload> parameters +JAVASCRIPTING: The B<-script>, B<-noScript>, B<-onLoad> and B<-onUnload> parameters are used to add Netscape JavaScript calls to your pages. B<-script> should point to a block of text containing JavaScript function definitions. This block will be placed within a <SCRIPT> block inside @@ -3242,6 +3255,10 @@ B<-script> field: print $query->start_html(-title=>'The Riddle of the Sphinx', -script=>$JSCRIPT); +Use the B<-noScript> parameter to pass some HTML text that will be displayed on +browsers that do not have JavaScript (or browsers where JavaScript is turned +off). + See http://home.netscape.com/eng/mozilla/2.0/handbook/javascript/ @@ -3281,7 +3298,7 @@ place to put Netscape extensions, such as colors and wallpaper patterns. This ends an HTML document by printing the </BODY></HTML> tags. -=head1 CREATING FORMS: +=head1 CREATING FORMS I<General note> The various form-creating methods all return strings to the caller, containing the tag or tags that will create the requested @@ -4506,7 +4523,7 @@ one of 'POST', 'GET' or 'HEAD'. =back -=head1 CREATING HTML ELEMENTS: +=head1 CREATING HTML ELEMENTS In addition to its shortcuts for creating form elements, CGI.pm defines general HTML shortcut methods as well. HTML shortcuts are |