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
Assignees
Labels
Milestone

Comments

@reschke
Copy link

@reschke 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.

@sdeleuze

This comment has been minimized.

Copy link
Contributor

@sdeleuze sdeleuze commented Apr 25, 2019

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

This comment has been minimized.

Copy link
Contributor

@sdeleuze sdeleuze commented Apr 29, 2019

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

@sdeleuze

This comment has been minimized.

Copy link
Contributor

@sdeleuze sdeleuze commented Apr 29, 2019

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

@sdeleuze

This comment has been minimized.

Copy link
Contributor

@sdeleuze sdeleuze commented Apr 29, 2019

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
@sdeleuze sdeleuze closed this in 89454e6 Apr 30, 2019
@reschke

This comment has been minimized.

Copy link
Author

@reschke 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)
jogu added a commit to openid-certification/conformance-suite that referenced this issue Oct 19, 2019
As per spring-projects/spring-framework#22788

Does not change anything in the core tests, deliberately as FAPI ID2
explicitly mentions the variant with charset, though this is likely
to change in the next draft:

https://bitbucket.org/openid/fapi/issues/236/charset-not-needed-for-application-json
jogu added a commit to openid-certification/conformance-suite that referenced this issue Oct 19, 2019
This is new in SpringBoot 2.2

As per:

spring-projects/spring-framework#22788

https://bitbucket.org/openid/fapi/issues/236/charset-not-needed-for-application-json

the current FAPI specs require the utf8 charset to be sent/requested for the
application/json mimetype, which is not necessary as no charset parameter is
defined for it.
timja added a commit to hmcts/draft-store that referenced this issue Oct 24, 2019
Fix test
charset is deprecated in spring and they no longer put it on exception
responses, see
https://github.com/spring-projects/spring-framework/issues/22788<Paste>
> Deprecated as of Spring Framework 5.2 in favor of APPLICATION_JSON_VALUE since major browsers like Chrome now comply with the specification  and interpret correctly UTF-8 special characters without requiring a charset=UTF-8 parameter.
timja added a commit to hmcts/draft-store that referenced this issue Oct 24, 2019
* Update deps to fix owasp

* Fix test

charset is deprecated in spring and they no longer put it on exception
responses, see
https://github.com/spring-projects/spring-framework/issues/22788<Paste>
> Deprecated as of Spring Framework 5.2 in favor of APPLICATION_JSON_VALUE since major browsers like Chrome now comply with the specification  and interpret correctly UTF-8 special characters without requiring a charset=UTF-8 parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.