richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

Fix UTF-8 encoded error #324

Closed QQBoxy closed 2 years ago

QQBoxy commented 2 years ago

I found that in the 1.4.0 update, the Busboy version was updated from 0.3.1 to version 1.6.0.

But the version after Busboy 1.0.0 has removed the encoding, which means that the encoding will be handled by the user.

So in the current express-fileupload 1.4.0 version, the filename will get the wrong encoding:

Correct: 許功蓋.jpg Wrong: 許å\u008a\u009fè\u0093\u008b.jpg

First I tried changing uriDecodeFileNames to true , but it didn't work.

Then I found the Busboy Issue where someone solved this problem: https://github.com/mscdex/busboy/issues/274#issuecomment-1015483307

After I modified it with reference to this method, the current encoding is correct, I hope it will help you, thank you.

gjf7 commented 2 years ago

Hi @QQBoxy ! Thanks for your time to help make this middleware better !

For this problem, Busboy do provide a option to solve this problem, so I don't think this is the middleware job to do for user! See #319

What do you think about it ? @richardgirges

QQBoxy commented 2 years ago

This problem can be solved by setting the default character of busboy, thanks for sharing.

I'll close this PR.