summaryrefslogtreecommitdiffstats
path: root/CGI.pl
diff options
context:
space:
mode:
authorterry%netscape.com <>1999-04-08 23:40:45 +0200
committerterry%netscape.com <>1999-04-08 23:40:45 +0200
commit09a62e442b2d5665434ad87ff1f5198aad36d648 (patch)
tree67fe21aa9a995d3c2750e19c6f2d751923249406 /CGI.pl
parentef5afae9ef7289847b53f9e4791e6e6dfd5d6039 (diff)
downloadbugzilla-09a62e442b2d5665434ad87ff1f5198aad36d648.tar.gz
bugzilla-09a62e442b2d5665434ad87ff1f5198aad36d648.tar.xz
Bugzilla now has the ability to store patches and other attachments with bugs.
Diffstat (limited to 'CGI.pl')
-rw-r--r--CGI.pl60
1 files changed, 58 insertions, 2 deletions
diff --git a/CGI.pl b/CGI.pl
index fa3acb93e..890a8edf7 100644
--- a/CGI.pl
+++ b/CGI.pl
@@ -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;
}