From: cjwatson <> Date: Tue, 1 Jun 2004 07:41:26 +0000 (-0800) Subject: [project @ 2004-06-01 00:41:26 by cjwatson] X-Git-Tag: release/2.6.0~749 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b0e3a006c6b3b59df94d6b02b74c441dd98f98e4;p=debbugs.git [project @ 2004-06-01 00:41:26 by cjwatson] Use RFC2616-compliant means of recommending a target filename to the browser when downloading attachments. Patch slightly modified from one by Tollef Fog Heen. --- diff --git a/cgi/bugreport.cgi b/cgi/bugreport.cgi index fca38140..324b4a15 100755 --- a/cgi/bugreport.cgi +++ b/cgi/bugreport.cgi @@ -88,9 +88,14 @@ sub display_entity ($$$$\$\@) { my $head = $entity->head; chomp(my $type = $entity->effective_type); my $body = $entity->stringify_body; - print "Content-Type: $type"; - print "; name=$filename" if $filename ne ''; - print "\n\n"; + print "Content-Type: $type\n"; + if ($filename ne '') { + my $qf = $filename; + $qf =~ s/"/\\"/g; + $qf =~ s[.*/][]; + print qq{Content-Disposition: attachment; filename="$qf"\n}; + } + print "\n"; my $decoder = new MIME::Decoder($head->mime_encoding); $decoder->decode(new IO::Scalar(\$body), \*STDOUT); exit(0);