Android icon indicating copy to clipboard operation
Android copied to clipboard

[Bug] Download dialog does not decode multibyte file name

Open Kita2345 opened this issue 3 years ago • 5 comments

Describe the bug

File name could not be decoded: %E4%B8%AD%E6%96%87%E6%96%87%E4%BB%B6%E5%90%8D%E6%B5%8B%E8%AF%95.txt

How to Reproduce

Download the test file here: https://wwa.lanzoui.com/iz4favlcrne

Expected behavior

Decoded as: 中文文件名测试.txt

Environment

- DDG App Version: 5.124.0
- Device:
- OS: Android 9

Kita2345 avatar May 11 '22 12:05 Kita2345

Able to reproduce. The download file has the current name. It only is displayed wrong in the app dialog.

vinc3nz avatar May 19 '22 12:05 vinc3nz

Sorry, could you provide more info about how to reproduce this? (e.g: where should I click, etc)

cmonfortep avatar Jul 07 '22 09:07 cmonfortep

Screenshot_20220707161909

Kita2345 avatar Jul 07 '22 09:07 Kita2345

Screenshot_20220707162143

Kita2345 avatar Jul 07 '22 09:07 Kita2345

Thank you for the info provided. We are able to reproduce the behaviour you mentioned.

We looked at the headers sent with the request to download the file and noticed the "Content-Disposition" header does not provide an indication that the filename is encoded:

Content-Disposition: attachment; filename= %E4%B8%AD%E6%96%87%E6%96%87%E4%BB%B6%E5%90%8D%E6%B5%8B%E8%AF%95.txt

Some browsers choose to do more processing on the filename value, while others don't. For example, when using Firefox I get the downloaded file as "%E4%B8%AD%E6%96%87%E6%96%87%E4%BB%B6%E5%90%8D%E6%B5%8B%E8%AF%95.txt", while with Chrome I get "中文文件名测试.txt".

In case of encoded filenames, the "filename*" param should be used as per RFC6266. We don't have support for this at the moment. Once it will be implemented, a header like:

Content-Disposition: attachment; filename*=utf-8''%E4%B8%AD%E6%96%87%E6%96%87%E4%BB%B6%E5%90%8D%E6%B5%8B%E8%AF%95.txt

will give the expected filename. This is a simplified example, there are a number of conditions that go into detecting the name of a file to download.

Asana task (internal only) -> https://app.asana.com/0/1200905986587319/1202994708537217/f

anikiki avatar Sep 16 '22 13:09 anikiki

Closing as something we will fix internally.

cmonfortep avatar Dec 16 '22 12:12 cmonfortep