]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2004-06-01 00:41:26 by cjwatson]
authorcjwatson <>
Tue, 1 Jun 2004 07:41:26 +0000 (23:41 -0800)
committercjwatson <>
Tue, 1 Jun 2004 07:41:26 +0000 (23:41 -0800)
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

index fca381404fc0366257c8a0a7306080016eb40a68..324b4a15a10ad905e577b1f89eb22649f51f7035 100755 (executable)
@@ -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);