From b0e3a006c6b3b59df94d6b02b74c441dd98f98e4 Mon Sep 17 00:00:00 2001 From: cjwatson <> Date: Mon, 31 May 2004 23:41:26 -0800 Subject: [PATCH] [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. --- cgi/bugreport.cgi | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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); -- 2.39.5