@@ -12,23 +12,24 @@ type Parser struct {
12
12
// If populated, only these methods will be considered valid.
13
13
validMethods []string
14
14
15
- // Use JSON Number format in JSON decoder.
16
- useJSONNumber bool
17
-
18
15
// Skip claims validation during token parsing.
19
16
skipClaimsValidation bool
20
17
21
18
validator * validator
22
19
23
- decoders
20
+ decoding
24
21
}
25
22
26
- type decoders struct {
23
+ type decoding struct {
27
24
jsonUnmarshal JSONUnmarshalFunc
28
25
jsonNewDecoder JSONNewDecoderFunc [JSONDecoder ]
29
26
30
27
rawUrlBase64Encoding Base64Encoding
31
28
urlBase64Encoding Base64Encoding
29
+ strict StrictFunc [Base64Encoding ]
30
+
31
+ // Use JSON Number format in JSON decoder.
32
+ useJSONNumber bool
32
33
33
34
decodeStrict bool
34
35
decodePaddingAllowed bool
@@ -246,13 +247,15 @@ func (p *Parser) DecodeSegment(seg string) ([]byte, error) {
246
247
}
247
248
248
249
if p .decodeStrict {
249
- // For now we can only support the standard library here because of the
250
- // current state of the type parameter system
251
- stricter , ok := encoding .(Stricter [* base64.Encoding ])
252
- if ! ok {
253
- return nil , newError ("strict mode is only supported in encoding/base64" , ErrUnsupported )
250
+ if p .strict != nil {
251
+ encoding = p .strict ()
252
+ } else {
253
+ stricter , ok := encoding .(Stricter [* base64.Encoding ])
254
+ if ! ok {
255
+ return nil , newError ("WithStrictDecoding() was enabled but supplied base64 encoder does not support strict mode" , ErrUnsupported )
256
+ }
257
+ encoding = stricter .Strict ()
254
258
}
255
- encoding = stricter .Strict ()
256
259
}
257
260
258
261
return encoding .DecodeString (seg )
0 commit comments