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

feat(protocol): ignore padding for base64 url encoding #95

Merged
merged 4 commits into from
Jan 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(protocol): ignore padding for base64 url encoding
This adds support to ignore the trailing padding of base64 URL encoded bytes.
  • Loading branch information
james-d-elliott committed Jan 24, 2023
commit 9694fdc3f1bb0a35b0691a1961b3561e5411819b
5 changes: 5 additions & 0 deletions protocol/base64.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ func (e *URLEncodedBase64) UnmarshalJSON(data []byte) error {
return nil
}

// TODO: Investigate this line. It is commented as trimming the leading spaces but appears to trim the leading and trailing double quotes instead.
// Trim the leading spaces
data = bytes.Trim(data, "\"")

// Trim the trailing equal characters.
data = bytes.TrimRight(data, "=")

out := make([]byte, base64.RawURLEncoding.DecodedLen(len(data)))
n, err := base64.RawURLEncoding.Decode(out, data)
if err != nil {
Expand Down