Skip to content

Commit cde46db

Browse files
committed
json: trim payload before checking it
1 parent bfe57f3 commit cde46db

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

json.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package jwt
22

3-
import "errors"
3+
import (
4+
"bytes"
5+
"errors"
6+
)
47

58
// ErrNotJSONObject is the error for when a JWT payload is not a JSON object.
69
var ErrNotJSONObject = errors.New("jwt: payload is not a valid JSON object")
710

811
func isJSONObject(payload []byte) bool {
12+
payload = bytes.TrimSpace(payload)
913
return payload[0] == '{' && payload[len(payload)-1] == '}'
1014
}

0 commit comments

Comments
 (0)