-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
fix base64 decode related builtin function #263
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proper handling of null bytes in the decode output and ignoring decoding errors definitely gets us closer to matching Fastly's behavior but there's still one issue.
Invalid characters are skipped entirely when decoding, and do not contribute to the bits for the current byte being output. Decoding continues for subsequent data as if the invalid character were not present.
Since the go decoder stops processing the input on invalid characters they should first be removed from the input before passing to the decoder.
I looked into Fastly documentation and improved base64-ed string dealing with corresponding functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, just a couple questions on the diff.
Sorry for not getting to this sooner I briefly looked at it when you submitted it and didn't have time to do a real review and forgot to leave the notification marked as unread. Oops.
LGTM |
Fixes #255
Fastly terminates null-byte on a decoded string in base64 decoding functions:
digest.base64_decode
digest.base64url_decode
digest.base64url_decode_nopad
Additionally,
digest.base64url_decode_nopad
also stops decoding when a padding sign (=
) is found.This PR follows Fastly behavior that describes the documentation.