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

@base64d fails with base64 encoded string without padding #1555

Closed
sebthom opened this issue Feb 13, 2023 · 1 comment · Fixed by #1604
Closed

@base64d fails with base64 encoded string without padding #1555

sebthom opened this issue Feb 13, 2023 · 1 comment · Fixed by #1604

Comments

@sebthom
Copy link

sebthom commented Feb 13, 2023

Describe the bug
I am trying to use yq to decode the payload of a JWT token.

While this works with jq using

$ jq -R 'split(".") | .[1] | @base64d | fromjson' <<< "$MY_TOKEN"
{
  //...
}

It fails with yq:

$ yq 'split(".") | .[1] | @base64d | fromjson' <<< "$MY_TOKEN"
Error: unexpected EOF

yq fails because JWT tokens consist of base64 components that are not padded using equals signs.

$ echo "dGVzdA==" | yq "@base64d"
test
$ echo "dGVzdA" | yq "@base64d"
Error: unexpected EOF

Version of yq: 4.30.8
Operating systems: mac/linux/windows
Installed via: binary release

Actual behavior

$ echo "dGVzdA" | yq "@base64d"
Error: unexpected EOF

Expected behavior

yq can handle base64 strings that are not padded.

$ echo "dGVzdA" | yq "@base64d"
test # this should be returned

Additional context
Add any other context about the problem here.

@mikefarah
Copy link
Owner

Released in 4.32.1 - Thanks again @teejaded :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants