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

Always use UTF-8 in GsonDeserializer #592

Merged
merged 1 commit into from
Jun 8, 2020
Merged

Always use UTF-8 in GsonDeserializer #592

merged 1 commit into from
Jun 8, 2020

Conversation

oleg-kuzych
Copy link
Contributor

@oleg-kuzych oleg-kuzych commented May 15, 2020

Hello,

in this piece of code:

    protected T readValue(byte[] bytes) throws IOException {
        return gson.fromJson(new String(bytes), returnType);
    }

new String(bytes) will use system default Charset, while UTF-8 should be used according to JWT RFC: https://tools.ietf.org/html/rfc7519#section-7.2

So, if JVM was started with "-Dfile.encoding=ISO-8859-1" system property then GsonDeserializer corrupts data during deserialization:
jjwt_unicode

…file.encoding" system property's value being used by JVM
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 690c812 on oleg-kuzych:fix-gson-unicode-deserialization-issue into 403e189 on jwtk:master.

@lhazlewood lhazlewood added this to the 0.11.2 milestone Jun 8, 2020
@lhazlewood lhazlewood merged commit d8c313c into jwtk:master Jun 8, 2020
@oleg-kuzych oleg-kuzych deleted the fix-gson-unicode-deserialization-issue branch June 8, 2020 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants