简体   繁体   中英

Umlauts in filenames are replaced with dots

So a user tried to uplaod some files with umlauts in the filename to my system (the system is running apache2 with laravel acting as the framework). What the script does is it uploads the files to the server and saves an entry in the DB (the encoding is utf8_general_ci).But when he tries to download the files he gets an "file not found" error. I looked at it and the files have been uploaded correctly to the server.When I downloaded them and looked at the filenames in the console they appear likes this:

看截图

You will notice that the last file is shown correctly. I tried renaming it and I just replaced the umlaut letter with the same letter and that fixed it.Do you know what the problem might be?

Check out which type of encoding your upload script use. The possible solution is rename file before saving on disk and DB (allow only az and numbers), its good practice.

Sounds like a case of missing Unicode normalization.

There are multiple ways to encode some glyphs. For example, ä can be expressed using a precomposed single glyph U+00E4 or as a combining sequence of a ( U+0061 ) followed by a combining diaeresis (U+0308) .

Your code should decide on a single Unicode normalization (depends on your platform which one -- if, like the screenshot seems to suggest, you are on Wintendo, I suppose NFKC, but it's not a platform I am very friendly with) and ensure all file names are normalized before attempting to open a file.

For more information, see https://en.wikipedia.org/wiki/Unicode_equivalence

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM