downloading attachments results in corrupt filename

Bug #1251335 reported by Paul Rentschler
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Eventum
Fix Released
Low
Elan Ruusamäe

Bug Description

Using IE 10 on Windows 7, clicking the link to download a file attached to a ticket prompts me to:
Do you want to save =_UTF-8_B_VGVzdEZpbGUueGzzeA==_= (7.86 KB) from example.com?

There is no problem downloading the attachment in Firefox 24.0, Chrome 30.0.1599.101 m, or Opera 16.0.1196.73. The problem also occurs using Safari 5.1.7 (7534.57.2)

Looking at the code and doing a bit of research led me to: http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http

And the problem appears to be in mime encoding the filename in the Attachment::outputDownload() method (line 82).

Changing line 82 to the following:

$filename = rawurlencode($filename);

and changing line 84 to the following:

header("Content-Disposition: {$disposition}; filename=\"{$filename}\"; filename*=UTF-8''{$filename}");

Has produced results that work in all 5 browsers listed above.

I do not have the resources to test this fix on Mac or Linux or to test it with other character sets/languages so further tested is warranted.

Revision history for this message
Elan Ruusamäe (glen666) wrote :

but if you use:

        $filename = rawurlencode($filename);

instead of:
        $filename = Mime_Helper::encodeQuotedPrintable($filename);

does that work nicely for you?

I'ts ok with Chrome 29 for Linux here.

Revision history for this message
Elan Ruusamäe (glen666) wrote :

i mean ONLY doing rawurlencode, not changing Content-Disposition header

Revision history for this message
Paul Rentschler (2-paul) wrote :

I just tested it and yes, changing just the encoding and not the Content-Disposition header does work in all 5 browsers that I have to test in.

From what I read, my concern would be if only changing the encoding would work in older browsers and if it would work when there are non US-ASCII characters present in the filename.

Revision history for this message
Elan Ruusamäe (glen666) wrote :

thanks, i gave internally someone to test with bunch of browsers, i'll see what his tests came back with

Revision history for this message
Elan Ruusamäe (glen666) wrote :

safari win7 5.1.7 (7534.57.2), fails to decode: om%C3%A1%C4%8Dka%20there.bin

firefox on windows, and ie10, ie11 seem fine with the patch

Revision history for this message
Elan Ruusamäe (glen666) wrote :

applied r4611 (eac31b9)

Changed in eventum:
milestone: none → 2.3.4
assignee: nobody → Elan Ruusamäe (glen666)
importance: Undecided → Low
status: New → Fix Committed
Elan Ruusamäe (glen666)
Changed in eventum:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.