@@ -12,23 +12,24 @@ type Parser struct {
1212	// If populated, only these methods will be considered valid. 
1313	validMethods  []string 
1414
15- 	// Use JSON Number format in JSON decoder. 
16- 	useJSONNumber  bool 
17- 
1815	// Skip claims validation during token parsing. 
1916	skipClaimsValidation  bool 
2017
2118	validator  * validator 
2219
23- 	decoders 
20+ 	decoding 
2421}
2522
26- type  decoders  struct  {
23+ type  decoding  struct  {
2724	jsonUnmarshal   JSONUnmarshalFunc 
2825	jsonNewDecoder  JSONNewDecoderFunc [JSONDecoder ]
2926
3027	rawUrlBase64Encoding  Base64Encoding 
3128	urlBase64Encoding     Base64Encoding 
29+ 	strict                StrictFunc [Base64Encoding ]
30+ 
31+ 	// Use JSON Number format in JSON decoder. 
32+ 	useJSONNumber  bool 
3233
3334	decodeStrict          bool 
3435	decodePaddingAllowed  bool 
@@ -246,13 +247,15 @@ func (p *Parser) DecodeSegment(seg string) ([]byte, error) {
246247	}
247248
248249	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 ()
254258		}
255- 		encoding  =  stricter .Strict ()
256259	}
257260
258261	return  encoding .DecodeString (seg )
0 commit comments