summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjustdave%syndicomm.com <>2004-02-04 10:52:20 +0100
committerjustdave%syndicomm.com <>2004-02-04 10:52:20 +0100
commit4831ddd26807c9868baec3645255e2b762547ac0 (patch)
tree525c5dba5666765f20b4c11b0be3b1d629dc1b50
parent545a42a0c5479198e4400ff45afae4271e79d671 (diff)
downloadbugzilla-4831ddd26807c9868baec3645255e2b762547ac0.tar.gz
bugzilla-4831ddd26807c9868baec3645255e2b762547ac0.tar.xz
Bug 232993: Quote the filenames in the Content-disposition header when downloading attachments. This allows spaces to be used in filenames, and fixes compliance with RFCs 2183, 2045, and 822.
r= myk, a= justdave
-rwxr-xr-xattachment.cgi6
1 files changed, 5 insertions, 1 deletions
diff --git a/attachment.cgi b/attachment.cgi
index c61b999e0..fd9983841 100755
--- a/attachment.cgi
+++ b/attachment.cgi
@@ -480,8 +480,12 @@ sub view
$filename =~ s/^.*[\/\\]//;
my $filesize = length($thedata);
+ # escape quotes and backslashes in the filename, per RFCs 2045/822
+ $filename =~ s/\\/\\\\/g; # escape backslashes
+ $filename =~ s/"/\\"/g; # escape quotes
+
print Bugzilla->cgi->header(-type=>"$contenttype; name=\"$filename\"",
- -content_disposition=> "inline; filename=$filename",
+ -content_disposition=> "inline; filename=\"$filename\"",
-content_length => $filesize);
print $thedata;