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

MockHttpServletResponse defaults to ISO-8859-1 for JSON while the rest of the framework defaults to UTF-8 #33019

Closed
lukas-krecan opened this issue Jun 13, 2024 · 0 comments
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@lukas-krecan
Copy link
Contributor

Affects: 6.1.8

When Spring MVC serializes JSON and no charater encoding is specified, UTF-8 is used by default (see this or this).

MockMvc on the other hand always defaults to ISO-8859-1 which results in inconsistencies reproduced here.

This is a follow-up of #32997

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 13, 2024
@jhoeller jhoeller added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Jun 13, 2024
@sdeleuze sdeleuze self-assigned this Jun 13, 2024
@snicoll snicoll added in: test Issues in the test module and removed in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jun 13, 2024
@sdeleuze sdeleuze added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 13, 2024
@sdeleuze sdeleuze added this to the 6.2.0-M5 milestone Jun 13, 2024
@snicoll snicoll changed the title MockMVC defaults to ISO-8859-1 for JSON while the rest of the framework defaults to UTF-8 MockHttpServletResponse defaults to ISO-8859-1 for JSON while the rest of the framework defaults to UTF-8 Jun 13, 2024
@sdeleuze sdeleuze changed the title MockHttpServletResponse defaults to ISO-8859-1 for JSON while the rest of the framework defaults to UTF-8 MockHttpServletResponse defaults to ISO-8859-1 for JSON while the rest of the framework defaults to UTF-8 Jun 13, 2024
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Jun 13, 2024
This commit makes MockHttpServletResponse consistent with the other
parts of the framework where the body of a response is read as an UTF-8
String when the content type is application/json or similar, overriding
the ISO-8859-1 default Servlet encoding.

Closes spring-projectsgh-33019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants