jaydenseric / graphql-upload

Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
https://npm.im/graphql-upload
MIT License
1.43k stars 131 forks source link

Support non `latin1` characters in file names #328

Closed mks1948 closed 2 years ago

mks1948 commented 2 years ago

After update from 14.0 to 15 i saw that is problem with non latin characters. Package does not work correctly and after finish upload return some weird characters. Please test with file name as : 你好.jpeg , معطل.jpeg or similar.

jaydenseric commented 2 years ago

If there is a problem with this, the v15.0.0 change most likely to be related would be the busboy dependency being updated to v1.

Package does not work correctly and after finish upload return some weird characters.

Can you please explain what happens more specifically? Where are the "weird characters".

mks1948 commented 2 years ago

After upload file for example "你好.jpeg" i got a name as "ä½ å¥½.jpeg"

jaydenseric commented 2 years ago

What if you do:

console.log(Buffer.from(strangeName, "latin1").toString("utf-8"));

Does it log the right way?

mks1948 commented 2 years ago

Yup this log working correctly but i think that is not way to fix it in my code :)

jaydenseric commented 2 years ago

Yes, you shouldn't need to do that when this bug is fixed.

jaydenseric commented 2 years ago

This should be fixed in v16.0.1 🚀

Be sure to remove any Buffer.from(strangeName, "latin1").toString("utf-8") workarounds before updating.