Skip to content

Commit

Permalink
feat(protocol): ignore padding for base64 url encoding
Browse files Browse the repository at this point in the history
This adds support to ignore the trailing padding of base64 URL encoded bytes.
  • Loading branch information
james-d-elliott committed Jan 24, 2023
1 parent c2e06ed commit fa6fedb
Showing 1 changed file with 5 additions and 0 deletions.
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.TrimSuffix(data, []byte{0x3d})

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

0 comments on commit fa6fedb

Please sign in to comment.