diff options
author | Dylan William Hardison <dylan@hardison.net> | 2018-10-05 17:10:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-05 17:10:13 +0200 |
commit | a1a8968653a1b2cf24991651d655229731be6fd9 (patch) | |
tree | 2752636903bdc66c1c9884883400a73ee540e87b | |
parent | f564933fdd8a06d44c4d5cc81a5c3e49e7be8928 (diff) | |
download | bugzilla-a1a8968653a1b2cf24991651d655229731be6fd9.tar.gz bugzilla-a1a8968653a1b2cf24991651d655229731be6fd9.tar.xz |
Bug 1496172 - Attachments with unicode filenames cause timeout errors when retreiving attachments
-rwxr-xr-x | attachment.cgi | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/attachment.cgi b/attachment.cgi index 875de6a50..e1009c18e 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -27,11 +27,11 @@ use Bugzilla::Attachment::PatchReader; use Bugzilla::Token; use Bugzilla::Keyword; use Bugzilla::Hook; +use Mojo::Util qw(url_escape); use Encode qw(encode find_encoding from_to); use URI; use URI::QueryParam; -use URI::Escape qw(uri_escape_utf8); use File::Basename qw(basename); use MIME::Base64 qw(decode_base64); @@ -405,24 +405,10 @@ sub view { if Bugzilla->user->id; my $disposition = Bugzilla->params->{'allow_attachment_display'} ? 'inline' : 'attachment'; + my $filename_star = qq{UTF-8''} . url_escape( encode('UTF-8', $filename) ); - my $ascii_filename = $filename; - utf8::encode($ascii_filename); - from_to($ascii_filename, 'UTF-8', 'ascii'); - $ascii_filename =~ s/(["\\])/\\$1/g; - my $qfilename = qq{"$filename"}; - my $ufilename = qq{UTF-8''} . uri_escape_utf8($filename); - - my $filenames = "filename=$qfilename"; - if ($ascii_filename ne $filename) { - $filenames .= "; filename*=$ufilename"; - } - - # IE8 and older do not support RFC 6266. So for these old browsers - # we still pass the old 'filename' attribute. Modern browsers will - # automatically pick the new 'filename*' attribute. print $cgi->header(-type=> $contenttype, - -content_disposition=> "$disposition; $filenames", + -content_disposition=> "$disposition; filename*=$filename_star", -content_length => $attachment->datasize); disable_utf8(); print $attachment->data; |