Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreign character failure - unescape(encodeURIComponent(options.headers[key])); [Bug] #971

Open
2 tasks done
lemonbob opened this issue Apr 2, 2024 · 4 comments
Open
2 tasks done
Labels

Comments

@lemonbob
Copy link

lemonbob commented Apr 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Have you updated FilePond and its plugins?

  • I have updated FilePond and its plugins

Describe the bug

In sendRequest.js, the deprecated unescape() method is called on a encodeURIComponent string. The two methods are not compatible with one another and creates an error in PATCH requests when using foreign characters in the payload.

Reproduction

Upload a large file (requiring a PATCH request) that has foreign characters e.g. 'Test_错误获取风险数据.jpg'

Environment

- Device:Dell Latitude 5430
- OS:Windows 11
- Browser: Chrome 123.0.6312.86 (Official Build) (64-bit)
@lemonbob lemonbob added the bug label Apr 2, 2024
@rikschennink
Copy link
Collaborator

Thanks for reporting. So this doesn't happen when uploading without PATCH?

@lemonbob
Copy link
Author

lemonbob commented Apr 3, 2024

Hi Rik,

It relates to a header property Upload-Name. This only appears in the PATCH call and not the base networkcall if the file is small. When the filename has foreign characters, the "encodeURIComponent" and "unescape" cause the below corruption of file name which throws an error. It is browser related too, depending on how unescape has been implemented. Latest Chrome has the error.

As I understand it, unescape is deprecated and non-standard, which is possibly why this error has only recently happened.

In the below 24098_错误获取风险数据.png gets corrupted.

image

I believe it relates to this code here in sendRequest.js, where unescape and encodeURIComponent are incompatible. One encodes as unicode, the other is hexadecimal.

image

@rikschennink
Copy link
Collaborator

@lemonbob thanks for clarifying 🙏

@rikschennink
Copy link
Collaborator

I'm a bit hesitant to change this now, but I will address it in FilePond v5.

For now you can fix this by setting custom headers, see this example: #1016 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants