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

Support UTF-8 in DefaultPartHttpMessageReader #26736

Closed
saad14092 opened this issue Mar 26, 2021 · 2 comments
Closed

Support UTF-8 in DefaultPartHttpMessageReader #26736

saad14092 opened this issue Mar 26, 2021 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@saad14092
Copy link

saad14092 commented Mar 26, 2021

Affects: 5.3.4

After upgrading to Spring boot v2.4.3 and Spring v5.3.4. We noticed that when uploading files via Webflux, the filenames containing accentuated characters (i.e é,à...) end up as a jumbled mess in the destination.

I believe this is due to the fact that Spring now uses DefaultPartHttpMessageReader that uses ISO_8859_1 (default encoding for multipart/from-data) to read the Part instead of SynchronossPartHttpMessageReader that defaulted to UTF-8 in case no character encoding was specified .

I have added nio-multipart-parser as a dependency and configured my app as follows :

public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) { SynchronossPartHttpMessageReader partReader = new SynchronossPartHttpMessageReader(); MultipartHttpMessageReader multiPartReader = new MultipartHttpMessageReader(partReader); configurer.defaultCodecs().multipartReader(multiPartReader); configurer.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper)); configurer.defaultCodecs().maxInMemorySize(8 * 1024 * 1024); }

With this configuration the UTF-8 characters are correctly read once again. But we really want to benefit from the new Streaming Mode that comes with DefaultPartHttpMessageReader.

Can DefaultPartHttpMessageReader offer the possibility of overriding the default character encoding ?

I thank you in advance for your reply.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 26, 2021
@poutsma poutsma self-assigned this Mar 29, 2021
@poutsma poutsma added this to the 5.3.6 milestone Mar 29, 2021
@poutsma poutsma added in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 29, 2021
@poutsma
Copy link
Contributor

poutsma commented Mar 30, 2021

After bringing myself up to date with the latest specs (specifically RFC 7578), I have changed the default to UTF-8 (but also made it configurable).

@saad14092
Copy link
Author

@poutsma Well that was quick! Thank you.

Zoran0104 pushed a commit to Zoran0104/spring-framework that referenced this issue Aug 20, 2021
This commit changes the encoding used to parse multipart headers from
ISO-8859-1 to UTF-8, in accordance with RFC 7578.

Closes spring-projectsgh-26736
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this issue Mar 26, 2022
This commit changes the encoding used to parse multipart headers from
ISO-8859-1 to UTF-8, in accordance with RFC 7578.

Closes spring-projectsgh-26736
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants