Skip to content

Bugfix: Enable non-ascii characters in JWT#79

Open
tom-010 wants to merge 1 commit intoappsup-dart:masterfrom
tom-010:master
Open

Bugfix: Enable non-ascii characters in JWT#79
tom-010 wants to merge 1 commit intoappsup-dart:masterfrom
tom-010:master

Conversation

@tom-010
Copy link

@tom-010 tom-010 commented Feb 20, 2023

Problem: When processing the response from an OpenID-Provider, the string is not decoded using UTF-8. Therefore, no non-ascii characters like german "Umlaute" (like ä, ü, ö) are possible in the JWT and therefore in the name in the JWT (like Jürgen).

Fix: in lib/src/http_util.dart _processResponse: before calling json.decode of the response, first decode it via utf8.decode.

Result: Umlaute and other non-ascii characters are now possible in the JWT and its fields like the name.

Problem: When processing the response from an OpenID-Provider, the
string is not decoded using UTF-8. Therefore, no non-ascii
characters like german "Umlaute" (like ä, ü, ö) are possible in
the JWT and therefore in the name in the JWT (like Jürgen).

Fix: in `lib/src/http_util.dart` `_processResponse`: before calling
`json.decode` of the response, first decode it via `utf8.decode`.

Result: Umlaute and other non-ascii characters are now possible
in the JWT and its fields like the name.
@zigapovhe
Copy link

@rbellens Can this be merged please? Thanks!

@bvoq
Copy link

bvoq commented Jul 20, 2023

+1
I believe the change needs to be:
var body = isJson ? json.decode(utf8.decode(response.body.codeUnits)) : response.body;
instead...

@rbellens
Copy link
Contributor

As @bvoq mentions, utf8.decode takes an List<int>, not a String, so this PR will not work. Can you update accordingly and also add a unit test.

@mahmoudysleim
Copy link

pls merge this pr we have this problem in arabic characters

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.

5 participants