honour response charset in gson and jackson iterator decoders#3447
Open
alhudz wants to merge 1 commit into
Open
honour response charset in gson and jackson iterator decoders#3447alhudz wants to merge 1 commit into
alhudz wants to merge 1 commit into
Conversation
GsonDecoder, JacksonIteratorDecoder and Jackson3IteratorDecoder read the response body with asReader(UTF_8), ignoring response.charset(). A non-UTF-8 charset declared on the response (e.g. charset=ISO-8859-1) is mis-decoded to U+FFFD. The sibling JSON decoders all pass response.charset(); do the same here. Signed-off-by: Alhuda Khan <al.hudz.k@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repro: a server response with
Content-Type: application/json; charset=ISO-8859-1and anISO-8859-1encoded body decoded throughGsonDecoder,JacksonIteratorDecoderorJackson3IteratorDecoder.Cause: those three read the body with
asReader(UTF_8), droppingresponse.charset(), so non-ASCII bytes come back asU+FFFD. The siblingJacksonDecoder,Jackson3Decoder,Fastjson2Decoder,JacksonJrDecoderandJsonDecoderalready passresponse.charset().Fix: pass
response.charset()in the three decoders, matching the siblings.response.charset()already defaults to UTF-8, so plain UTF-8 responses are unchanged. Regression test added per module.