diff options
author | terry%netscape.com <> | 1999-04-08 21:40:45 +0000 |
---|---|---|
committer | terry%netscape.com <> | 1999-04-08 21:40:45 +0000 |
commit | 09a62e442b2d5665434ad87ff1f5198aad36d648 (patch) | |
tree | 67fe21aa9a995d3c2750e19c6f2d751923249406 /CGI.pl | |
parent | ef5afae9ef7289847b53f9e4791e6e6dfd5d6039 (diff) | |
download | bugs-09a62e442b2d5665434ad87ff1f5198aad36d648.tar bugs-09a62e442b2d5665434ad87ff1f5198aad36d648.tar.gz bugs-09a62e442b2d5665434ad87ff1f5198aad36d648.tar.bz2 bugs-09a62e442b2d5665434ad87ff1f5198aad36d648.tar.xz bugs-09a62e442b2d5665434ad87ff1f5198aad36d648.zip |
Bugzilla now has the ability to store patches and other attachments with bugs.
Diffstat (limited to 'CGI.pl')
-rw-r--r-- | CGI.pl | 60 |
1 files changed, 58 insertions, 2 deletions
@@ -119,6 +119,54 @@ sub ProcessFormFields { } +sub ProcessMultipartFormFields { + my ($boundary) = (@_); + $boundary =~ s/^-*//; + my $remaining = $ENV{"CONTENT_LENGTH"}; + my $inheader = 1; + my $itemname = ""; +# open(DEBUG, ">debug") || die "Can't open debugging thing"; +# print DEBUG "Boundary is '$boundary'\n"; + while ($remaining > 0 && ($_ = <STDIN>)) { + $remaining -= length($_); +# print DEBUG "< $_"; + if ($_ =~ m/^-*$boundary/) { +# print DEBUG "Entered header\n"; + $inheader = 1; + $itemname = ""; + next; + } + + if ($inheader) { + if (m/^\s*$/) { + $inheader = 0; +# print DEBUG "left header\n"; + $::FORM{$itemname} = ""; + } + if (m/^Content-Disposition:\s*form-data\s*;\s*name\s*=\s*"([^\"]+)"/i) { + $itemname = $1; +# print DEBUG "Found itemname $itemname\n"; + if (m/;\s*filename\s*=\s*"([^\"]+)"/i) { + $::FILENAME{$itemname} = $1; + } + } + + next; + } + $::FORM{$itemname} .= $_; + } + delete $::FORM{""}; + # Get rid of trailing newlines. + foreach my $i (keys %::FORM) { + chomp($::FORM{$i}); + $::FORM{$i} =~ s/\r$//; + } +} + + + + + sub FormData { my ($field) = (@_); return $::FORM{$field}; @@ -475,10 +523,18 @@ if (defined $ENV{"REQUEST_METHOD"}) { } else { $::buffer = ""; } + ProcessFormFields $::buffer; } else { - read STDIN, $::buffer, $ENV{"CONTENT_LENGTH"} || die "Couldn't get form data"; + if ($ENV{"CONTENT_TYPE"} =~ + m@multipart/form-data; boundary=\s*([^; ]+)@) { + ProcessMultipartFormFields($1); + $::buffer = ""; + } else { + read STDIN, $::buffer, $ENV{"CONTENT_LENGTH"} || + die "Couldn't get form data"; + ProcessFormFields $::buffer; + } } - ProcessFormFields $::buffer; } |