Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
437d7e21
Commit
437d7e21
authored
Apr 13, 2016
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 619847 - Attachment filenames with UTF-8 characters download with an incorrect filename
Thanks to nE0sIghT for the original idea r=dkl
parent
f97a4634
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
attachment.cgi
attachment.cgi
+9
-9
No files found.
attachment.cgi
View file @
437d7e21
...
...
@@ -25,8 +25,8 @@ use Bugzilla::Attachment;
use
Bugzilla::Attachment::
PatchReader
;
use
Bugzilla::
Token
;
use
Encode
qw(
encode
find_encoding)
;
use
Encode::MIME::
Header
;
# Required to alter Encode::Encoding{'MIME-Q'}.
use
Encode
qw(find_encoding)
;
use
URI::
Escape
qw(uri_escape_utf8)
;
use
Cwd
qw(realpath)
;
# For most scripts we don't make $cgi and $template global variables. But
...
...
@@ -341,11 +341,8 @@ sub view {
# escape quotes and backslashes in the filename, per RFCs 2045/822
$filename
=~
s/\\/\\\\/g
;
# escape backslashes
$filename
=~
s/"/\\"/g
;
# escape quotes
# Avoid line wrapping done by Encode, which we don't need for HTTP
# headers. See discussion in bug 328628 for details.
local
$
Encode::
Encoding
{
'MIME-Q'
}
->
{
'bpl'
}
=
10000
;
$filename
=
encode
(
'MIME-Q'
,
$filename
);
# Follow RFC 6266 section 4.1 (which itself points to RFC 5987 section 3.2)
$filename
=
uri_escape_utf8
(
$filename
);
my
$disposition
=
(
Bugzilla
->
params
->
{
'allow_attachment_display'
}
&&
$attachment
->
is_viewable
)
?
'inline'
:
'attachment'
;
...
...
@@ -373,8 +370,11 @@ sub view {
my
$attachment_path
=
realpath
(
$attachment
->
_get_local_filename
());
$sendfile_header
->
{
$sendfile_param
}
=
$attachment_path
;
}
print
$cgi
->
header
(
-
type
=>
"$contenttype; name=\"$filename\""
,
-
content_disposition
=>
"$disposition; filename=\"$filename\""
,
# 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; filename=\"$filename\"; filename*=UTF-8''$filename"
,
-
content_length
=>
$attachment
->
datasize
,
%
$sendfile_header
);
if
(
$attachment
->
is_on_filesystem
&&
$sendfile_param
ne
'off'
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment