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

Deprecate MediaType.APPLICATION_JSON_UTF8 in favor of APPLICATION_JSON #22788

Closed
reschke opened this issue Apr 12, 2019 · 5 comments
Closed

Deprecate MediaType.APPLICATION_JSON_UTF8 in favor of APPLICATION_JSON #22788

reschke opened this issue Apr 12, 2019 · 5 comments
Assignees
Labels
type: task A general task
Milestone

Comments

@reschke
Copy link

reschke commented Apr 12, 2019

In spring-framework/spring-web/src/main/java/org/springframework/http/MediaType.java:

 * <p>This {@link MediaType#APPLICATION_JSON} variant should be used to set JSON
 * content type because while
 * <a href="https://tools.ietf.org/html/rfc7159#section-11">RFC7159</a>
 * clearly states that "no charset parameter is defined for this registration", some
 * browsers require it for interpreting correctly UTF-8 special characters
  1. RFC 7159 has been obsoleted by RFC 8259
  2. That states "No "charset" parameter is defined for this registration. Adding one really has no effect on compliant recipients." (at the end of Section 11)
  3. ...and browsers have indeed fixed their code.

So it would be best to clarify the text and deprecate the constant.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 12, 2019
@jhoeller jhoeller modified the milestones: 5.1.7, 5.2 M2 Apr 12, 2019
@sdeleuze sdeleuze self-assigned this Apr 12, 2019
@sdeleuze sdeleuze added type: documentation A documentation task type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged or decided on type: documentation A documentation task labels Apr 12, 2019
@sdeleuze
Copy link
Contributor

Indeed, the related Chrome bug discussed in #18178 is fixed since September 2017, and I have been able to validate that UTF-8 characters are now rendered correctly with Content-Type: application/json, so I am ok to switch back to MediaType.APPLICATION_JSON, deprecate MediaType.APPLICATION_JSON_UTF8 and update the documentation accordingly in Spring Framework 5.2.

@sdeleuze sdeleuze changed the title Misleading doc for MediaType.APPLICATION_JSON_UTF8 Deprecate MediaType.APPLICATION_JSON_UTF8 in favor of APPLICATION_JSON Apr 25, 2019
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Apr 25, 2019
This commit deprecates MediaType.APPLICATION_JSON_UTF8 in favor of
MediaType.APPLICATION_JSON since UTF-8 encoding is now handled correctly
by most browsers (related bug has been fixed in Chrome in October 2017).

Closes spring-projectsgh-22788
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Apr 25, 2019
This commit deprecates MediaType.APPLICATION_JSON_UTF8 and
MediaType.APPLICATION_PROBLEM_JSON_UTF8 in favor of
MediaType.APPLICATION_JSON and MediaType.APPLICATION_PROBLEM_JSON since
UTF-8 encoding is now handled correctly by most browsers
(related bug has been fixed in Chrome since September 2017).

Closes spring-projectsgh-22788
@sdeleuze
Copy link
Contributor

It is a shame, but Safari still has this bug so we should decide what to do ...

@sdeleuze
Copy link
Contributor

I have created https://bugs.webkit.org/show_bug.cgi?id=197369 on Safari bugtracker, let's see what is their feedback.

@sdeleuze
Copy link
Contributor

The Safari bug is only impacting the display in the main frame, not via XMLHttpRequest, so I think we can move forward and merge that in master.

sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Apr 30, 2019
This commit deprecates MediaType.APPLICATION_JSON_UTF8 and
MediaType.APPLICATION_PROBLEM_JSON_UTF8 in favor of
MediaType.APPLICATION_JSON and MediaType.APPLICATION_PROBLEM_JSON since
UTF-8 encoding is now handled correctly by most browsers
(related bug has been fixed in Chrome since September 2017).

Closes spring-projectsgh-22788
@reschke
Copy link
Author

reschke commented Apr 30, 2019

The Safari bug is only impacting the display in the main frame, not via XMLHttpRequest, ...

FWIW, I believe the same way true for the matching bugs in Chromium and Firefox.

sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue May 27, 2019
rj-hwang added a commit to simter/simter-operation that referenced this issue Jun 5, 2019
rj-hwang added a commit to simter/simter-kv that referenced this issue Jun 6, 2019
cordin added a commit to cordin/spring-petclinic-functional that referenced this issue Oct 3, 2019
Solve test error by removing the charset in the content type validation
as the default value has been changed in Spring Boot 2.2. See gh-22788
(spring-projects/spring-framework#22788)
sainaen added a commit to sainaen/rainbow-rest that referenced this issue Jan 29, 2020
In the newest versions of Spring Framework, after a change[1] to align
it with the RFC8259[2], the character encoding is no longer set to
UTF-8 for responses with `application/json` content-type.

Tomcat's `Response#getCharacterEncoding()` returns ISO-8895-1 if it is
not set explicitly.

This fix makes a `JsonResponseWrapper` use UTF-8 by default, instead of
getting charset from the wrapped `Response` instance which could have
been not set.

[1]: spring-projects/spring-framework#22788
[2]: https://tools.ietf.org/html/rfc8259#section-11
sainaen added a commit to sainaen/rainbow-rest that referenced this issue Jan 29, 2020
In the newest versions of Spring Framework, after a change[1] to align
it with the RFC8259[2], the character encoding is no longer set to
UTF-8 for responses with `application/json` content-type.

Tomcat's `Response#getCharacterEncoding()` returns ISO-8895-1 if it is
not set explicitly.

This fix makes a `JsonResponseWrapper` use UTF-8 by default, instead of
getting charset from the wrapped `Response` instance which could have
been not set.

[1]: spring-projects/spring-framework#22788
[2]: https://tools.ietf.org/html/rfc8259#section-11
sainaen added a commit to sainaen/rainbow-rest that referenced this issue Jan 29, 2020
In the newest versions of Spring Framework, after a change[1] to align
it with the RFC8259[2], the character encoding is no longer set to
UTF-8 for responses with `application/json` content-type.

Tomcat's `Response#getCharacterEncoding()` returns ISO-8895-1 if it is
not set explicitly.

This fix makes a `JsonResponseWrapper` use UTF-8 by default, instead of
getting charset from the wrapped `Response` instance which could have
been not set.

[1]: spring-projects/spring-framework#22788
[2]: https://tools.ietf.org/html/rfc8259#section-11
sainaen added a commit to sainaen/rainbow-rest that referenced this issue Jan 29, 2020
In the newest versions of Spring Framework, after a change[1] to align
it with the RFC8259[2], the character encoding is no longer set to
UTF-8 for responses with `application/json` content-type.

This fix makes a `JsonResponseWrapper` use UTF-8 by default, instead of
getting charset from the wrapped `Response` instance which could have
been not set and so it returns default ISO-8895-1.

[1]: spring-projects/spring-framework#22788
[2]: https://tools.ietf.org/html/rfc8259#section-11
sainaen added a commit to sainaen/rainbow-rest that referenced this issue Jan 29, 2020
In the newest versions of Spring Framework, after a change[1] to align
it with the RFC8259[2], the character encoding is no longer set to
UTF-8 for responses with `application/json` content-type.

This fix makes a `JsonResponseWrapper` use UTF-8 by default, instead of
getting charset from the wrapped `Response` instance which could have
been not set and so it returns default ISO-8895-1.

[1]: spring-projects/spring-framework#22788
[2]: https://tools.ietf.org/html/rfc8259#section-11
sainaen added a commit to sainaen/rainbow-rest that referenced this issue Jan 29, 2020
In the newest versions of Spring Framework, after a change[1] to align
it with the RFC8259[2], the character encoding is no longer set to
UTF-8 for responses with `application/json` content-type.

This fix makes a `JsonResponseWrapper` use UTF-8 by default, instead of
getting charset from the wrapped `Response` instance which could have
been not set and so it returns default ISO-8895-1.

[1]: spring-projects/spring-framework#22788
[2]: https://tools.ietf.org/html/rfc8259#section-11
alexeytokar pushed a commit to alexeytokar/rainbow-rest that referenced this issue Jan 29, 2020
In the newest versions of Spring Framework, after a change[1] to align
it with the RFC8259[2], the character encoding is no longer set to
UTF-8 for responses with `application/json` content-type.

This fix makes a `JsonResponseWrapper` use UTF-8 by default, instead of
getting charset from the wrapped `Response` instance which could have
been not set and so it returns default ISO-8895-1.

[1]: spring-projects/spring-framework#22788
[2]: https://tools.ietf.org/html/rfc8259#section-11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

No branches or pull requests

4 participants