silverwind / droppy

**ARCHIVED** Self-hosted file storage
BSD 2-Clause "Simplified" License
1.62k stars 196 forks source link

Can't download files with accented characters #419

Open daquinoaldo opened 4 years ago

daquinoaldo commented 4 years ago

Hi, thank you for this awesome project, I love it!

I'm an Italian user and I'm not able to download files with accented characters like àùòèéì. Is it possible that Droppy does not support UTF-8/16? I found a very old but similar issue #9 marked as resolved, but I still notice this problem. It's interesting that when uploading the file it is correctly uploaded and named with the accented letters as in the original file, only the download is affected. Moreover, I can download the folder containing the affected file without running into the bug.

Tronic commented 4 years ago

I'm having the same problem. It turns on that on my Mac accented characters are encoded with Unicode combining characters so that ä (U+00E4) becomes two characters ä (a + ¨, or more specifically U+0061 U+0308, or in UTF-8 61 CC 88). When uploading the file to Droppy, the same encoding is preserved on the Linux server, but in Droppy web UI it gets normalised to U+00E4, and trying to open the file by clicking it gives

2020-07-08 12:23:38 [ERROR] ENOENT: no such file or directory, stat '/srv/droppy/files/Meritähti.pdf'

By manually forming a URL like http://localhost/!/dl/Merita%CC%88hti.pdf the file can still be downloaded without errors.

Suggested fix: ensure that no Unicode normalisation occurs in URLs displayed in web UI, possibly by %-encoding any non-ASCII bytes early in the server code, prior to passing it to any other NodeJS frameworks.

Workaround for the end user: You may convert filenames on Mac or Linux by convmv tool. NFC is that shorter form that avoids combining characters and that should work with Droppy. Note that most Mac apps prefer the NFD form instead!

convmv -f UTF-8 -t UTF-8 --nfc -r /path/to/files