Requests with application/json Content-Type do not correctly assume UTF-8 charset
See original GitHub issue- Framework version: 1.1.1 - 1.1.3
- Implementations: All
Scenario
It seems that the changes for #150 broke the assumption that all JSON is UTF-8, by definition.
Expected behavior
Parsing a JSON request body to a Java type should assume UTF-8 charset.
Actual behavior
It does not correctly handle characters out of ascii set.
Steps to reproduce
Send request with appplication/json
in the Content-Type
header and strange characters such as »
in the JSON body. It will not be correctly parsed and throw a bad request.
If you set the Content-Type
header to application/json; charset=UTF-8
then it works fine, but should not be necessary and most REST clients won’t do it.
Full log output
Invalid UTF-8 middle byte 0x65\\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 13]\\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream);
Thanks for your support!
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
What does "Content-type: application/json; charset=utf-8 ...
Content -type: application/json; charset=utf-8 designates the content to be in JSON format, encoded in the UTF-8 character encoding. Designating the encoding ...
Read more >Make default charset UTF-8 when using `receiveText` for ...
Request with Content-Type: application/json is decoded not as UTF-8, while request with Content-Type: application/json; charset=utf-8 is decoded correctly.
Read more >Support non-Unicode character encoding in Azure Logic Apps
If you're using the Request trigger for text/plain content, you must set the charset parameter that is in the call's Content-Type header.
Read more >Character set in JSON file - Progress Community
What is the correct character set requested by the customer in the output file? I assume ... :ContentType('application/json;charset=UTF-8').
Read more >What does “Content-type: application/json; charset=utf-8 ...
Designating the encoding is somewhat redundant for JSON, since the default (only?) encoding for JSON is UTF-8. So in this case the receiving...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Perhaps I could add a field for this in the
ContainerConfig
object, default it toISO-8859-1
, but give you the ability to change this whenever you want:Thoughts?
That’s the plan.