{"action":"closed","issue":{"url":"https://api.github.com/repos/siemensikkema/vapor-jwt/issues/8","repository_url":"https://api.github.com/repos/siemensikkema/vapor-jwt","labels_url":"https://api.github.com/repos/siemensikkema/vapor-jwt/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/siemensikkema/vapor-jwt/issues/8/comments","events_url":"https://api.github.com/repos/siemensikkema/vapor-jwt/issues/8/events","html_url":"https://github.com/siemensikkema/vapor-jwt/issues/8","id":186154975,"number":8,"title":"Extraneous padding added by BytesTranscoder causes JWT decoding to fail","user":{"login":"alexaubry","id":16192914,"avatar_url":"https://avatars.githubusercontent.com/u/16192914?v=3","gravatar_id":"","url":"https://api.github.com/users/alexaubry","html_url":"https://github.com/alexaubry","followers_url":"https://api.github.com/users/alexaubry/followers","following_url":"https://api.github.com/users/alexaubry/following{/other_user}","gists_url":"https://api.github.com/users/alexaubry/gists{/gist_id}","starred_url":"https://api.github.com/users/alexaubry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexaubry/subscriptions","organizations_url":"https://api.github.com/users/alexaubry/orgs","repos_url":"https://api.github.com/users/alexaubry/repos","events_url":"https://api.github.com/users/alexaubry/events{/privacy}","received_events_url":"https://api.github.com/users/alexaubry/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-30T18:55:15Z","updated_at":"2016-10-31T12:46:59Z","closed_at":"2016-10-31T12:46:59Z","body":"When decoding a JWT from a string,  I get this error :\n\n```\n▿ Jay.JayError.extraTokensFound\n  ▿ extraTokensFound: Jay.ByteReader #0\n    ▿ content: 28 elements\n      - 123\n      - 34\n      - 116\n      - 121\n      - 112\n      - 34\n      - 58\n      - 34\n      - 74\n      - 87\n      - 84\n      - 34\n      - 44\n      - 34\n      - 97\n      - 108\n      - 103\n      - 34\n      - 58\n      - 34\n      - 72\n      - 83\n      - 50\n      - 53\n      - 54\n      - 34\n      - 125\n      - 0\n    - cursor: 27\n```\n\nThe JWT was `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.(...).(...)`.\n\nThis only happens when a Base64URL-encoded segment has `n` characters, where `n % 4 = 0`.\n\nAfter investigating the issue, I've noticed that `BytesTranscoder` adds a 4 characters-long padding in such cases when converting to Base64 (for example, `\"abcd\"` becomes `\"abcd====\"` and `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9` becomes `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9====`).\n\nThis extra padding then interpreted as a null byte by `Data(base64Encoded:)`. But according to [Wikipedia](https://en.wikipedia.org/wiki/Base64#Padding), when `n % 4 = 0` no padding characters should be added.\n"}}
{"actor":{"display_login":"siemensikkema"}}