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

Encoding issue #404

Closed
mathpere opened this issue May 12, 2015 · 1 comment · Fixed by #405
Closed

Encoding issue #404

mathpere opened this issue May 12, 2015 · 1 comment · Fixed by #405

Comments

@mathpere
Copy link

Hi,

When I'm trying to decode this token with satellizer:

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1NTUwZTNmNWI2YTRkMGE4MDM5ODkwZTAiLCJmaXJzdE5hbWUiOiJyb2LDqXJ0w6AiLCJsYXN0TmFtZSI6InRow6nDtCIsInJvbGVzIjpbInVzZXIiXSwiZW1haWwiOiJyb2JlcnRhLnRlb0BnbWFpbC5jb20iLCJpYXQiOjE0MzEzNjQ1OTcsImV4cCI6MTQzMjU3NDE5N30.cIWEwWdzbCWIVt98SFpwCEemmAsDffs4NoEIrJpv7Tg

I get this payload:

{
  "_id": "5550e3f5b6a4d0a8039890e0",
  "firstName": "robértà ",
  "lastName": "théô",
  "roles": [
    "user"
  ],
  "email": "[email protected]",
  "iat": 1431364597,
  "exp": 1432574197
}

whereas I was expecting the following:

{
  "_id": "5550e3f5b6a4d0a8039890e0",
  "firstName": "robértà",
  "lastName": "théô",
  "roles": [
    "user"
  ],
  "email": "[email protected]",
  "iat": 1431364597,
  "exp": 1432574197
}

When looking at angular-jwt lib, they prevent this issue by replacing
return JSON.parse($window.atob(base64)); at https://github.com/sahat/satellizer/blob/master/satellizer.js#L298
with
return JSON.parse(decodeURIComponent(escape(window.atob(base64)))); at https://github.com/auth0/angular-jwt/blob/master/dist/angular-jwt.js#L75

Are you interested in a pull request with this fix if you think it's a good idea?

@sahat
Copy link
Owner

sahat commented May 12, 2015

Hey @mathpere, sure I'd love a PR for this. It was negligence on my part for not testing inputs using non-english characters.

sahat added a commit that referenced this issue May 13, 2015
…_english_characters

[#404] encoding non-english 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 a pull request may close this issue.

2 participants