-
Notifications
You must be signed in to change notification settings - Fork 166
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
Corrupt filename in Upload component when server's file encoding is not UTF-8 #20417
Comments
@mas4ivv I was unfortunately unable to reproduce this on macOS (uses UTF-8 by default, but even changing the server JVM encoding to soemthing else did not break the special characters). Are you by any chance on Windows? |
Yes, the example was run on Jetty on Windows. Our production server is running on Linux and has the same problem. |
Alright, in that case it should be reproducable on mac as well since I think most Linux default to utf-8 anyway. I'll retry. |
@mas4ivv Could you please clarify these questions to help us reproducing the issue and find good fix for it. Also if possible, attaching full example application would also answer some of these:
Example code generates a request with content type of Updating Flow to always call |
Hi, I'm adding -Dfile.encoding=ISO8859-15 on startup, if I specify UTF-8 everything works fine. I added breakpoints at
so it seems that getItemIterator gets called as a fallback (this is the same for all encodings). I also tried setting |
Thank you. Key for reproducing was to run without multipart config so Flow will fallback to non-multipart upload. Setting header encoding always to UTF-8 in case when request's character encoding is not explicitly set seems now correct fix. This because |
This change will set ServletFileUpload's header encoding always to UTF-8 in StreamReceiverHandler when request character encoding is null. This ensures that system's default character encoding is not applied when parsing filename of the uploaded file, unless request's character encoding is set otherwise. Only for setups without multipart config for servlet. Fixes: #20417
This change will set ServletFileUpload's header encoding always to UTF-8 in StreamReceiverHandler when request character encoding is null. This ensures that system's default character encoding is not applied when parsing filename of the uploaded file, unless request's character encoding is set otherwise. Only for setups without multipart config for servlet. Fixes: #20417
This change will set ServletFileUpload's header encoding always to UTF-8 in StreamReceiverHandler when request character encoding is null. This ensures that system's default character encoding is not applied when parsing filename of the uploaded file, unless request's character encoding is set otherwise. Only for setups without multipart config for servlet. Fixes: #20417
* fix: fix ServletFileUpload header encoding (#20480) This change will set ServletFileUpload's header encoding always to UTF-8 in StreamReceiverHandler when request character encoding is null. This ensures that system's default character encoding is not applied when parsing filename of the uploaded file, unless request's character encoding is set otherwise. Only for setups without multipart config for servlet. Fixes: #20417 * chore: formatting * test: fixed test
This change will set ServletFileUpload's header encoding always to UTF-8 in StreamReceiverHandler when request character encoding is null. This ensures that system's default character encoding is not applied when parsing filename of the uploaded file, unless request's character encoding is set otherwise. Only for setups without multipart config for servlet. Fixes: #20417
This change will set ServletFileUpload's header encoding always to UTF-8 in StreamReceiverHandler when request character encoding is null. This ensures that system's default character encoding is not applied when parsing filename of the uploaded file, unless request's character encoding is set otherwise. Only for setups without multipart config for servlet. Fixes: #20417
* fix: fix ServletFileUpload header encoding (#20480) This change will set ServletFileUpload's header encoding always to UTF-8 in StreamReceiverHandler when request character encoding is null. This ensures that system's default character encoding is not applied when parsing filename of the uploaded file, unless request's character encoding is set otherwise. Only for setups without multipart config for servlet. Fixes: #20417 * test: fixed test * chore: formatting
* fix: fix ServletFileUpload header encoding (#20480) This change will set ServletFileUpload's header encoding always to UTF-8 in StreamReceiverHandler when request character encoding is null. This ensures that system's default character encoding is not applied when parsing filename of the uploaded file, unless request's character encoding is set otherwise. Only for setups without multipart config for servlet. Fixes: #20417 * chore: fixed test and formatting
This ticket/PR has been released with Vaadin 23.5.12. |
This ticket/PR has been released with Vaadin 24.4.18. |
Description of the bug
When using the Upload component with a filename that has non-ASCII characters, the server receives a corrupt filename if it's file encoding is not UTF-8.
The filename is part of the upload request and seems to be UTF-8 encoded:
The filename is then read via Apache Commons' ServletFileUpload, created by StreamReceiverHandler.getItemIterator(VaadinRequest). As there is no encoding set on creation, it falls back to the server's default.
Example running the example below from Windows command line:
Expected behavior
It seems to me that the client is always sending the filename UTF-8 encoded. If this is correct, the ServletFileUpload created in StreamReceiverHandler should be configured to use UTF-8 by calling setHeaderEncoding("UTF-8").
Minimal reproducible example
Versions
The text was updated successfully, but these errors were encountered: