# 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';
return @{$self->{'.parameters'}};
}
-
-
#### Method as_string
#
# synonym for "dump"
# $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.
'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
</SCRIPT>
END
;
+ push(@result,<<END) if $noscript;
+<NOSCRIPT>
+$noscript
+</NOSCRIPT>
+END
+ ;
my($other) = @other ? " @other" : '';
push(@result,"</HEAD><BODY$other>");
return join("\n",@result);
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.
# 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
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) = '';
# 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
$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
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:
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
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/
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
=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