44import org .slf4j .Logger ;
55import org .slf4j .LoggerFactory ;
66
7+ import java .io .UnsupportedEncodingException ;
78import java .net .URLDecoder ;
89import java .net .URLEncoder ;
10+ import java .nio .charset .StandardCharsets ;
911import java .util .ArrayList ;
1012import java .util .List ;
1113
@@ -22,8 +24,11 @@ public static List<AuthorizationValue> parse(String urlEncodedAuthStr) {
2224 for (String part : parts ) {
2325 String [] kvPair = part .split (":" );
2426 if (kvPair .length == 2 ) {
25- // FIXME replace the deprecated method by decode(string, encoding). Which encoding is used ? Default UTF-8 ?
26- auths .add (new AuthorizationValue (URLDecoder .decode (kvPair [0 ]), URLDecoder .decode (kvPair [1 ]), "header" ));
27+ try {
28+ auths .add (new AuthorizationValue (URLDecoder .decode (kvPair [0 ], StandardCharsets .UTF_8 .name ()), URLDecoder .decode (kvPair [1 ], StandardCharsets .UTF_8 .name ()), "header" ));
29+ } catch (UnsupportedEncodingException e ) {
30+ throw new AssertionError ("UTF-8 is not supported" , e );
31+ }
2732 }
2833 }
2934 }
@@ -38,9 +43,9 @@ public static String reconstruct(List<AuthorizationValue> authorizationValueList
3843 if (b .toString ().length () > 0 ) {
3944 b .append ("," );
4045 }
41- b .append (URLEncoder .encode (v .getKeyName (), "UTF-8" ))
46+ b .append (URLEncoder .encode (v .getKeyName (), StandardCharsets . UTF_8 . name () ))
4247 .append (":" )
43- .append (URLEncoder .encode (v .getValue (), "UTF-8" ));
48+ .append (URLEncoder .encode (v .getValue (), StandardCharsets . UTF_8 . name () ));
4449 } catch (Exception e ) {
4550 // continue
4651 LOGGER .error (e .getMessage (), e );
0 commit comments