SEC-2187: Polish
Create private utf8UrlEncode method to improve readability
This commit is contained in:
parent
54c1c20c69
commit
e88800cd9b
|
@ -188,7 +188,6 @@ public class OpenIDAuthenticationFilter extends AbstractAuthenticationProcessing
|
|||
* @return The <tt>return_to</tt> URL.
|
||||
*/
|
||||
protected String buildReturnToUrl(HttpServletRequest request) {
|
||||
try {
|
||||
StringBuffer sb = request.getRequestURL();
|
||||
|
||||
Iterator<String> iterator = returnToUrlParameters.iterator();
|
||||
|
@ -207,18 +206,13 @@ public class OpenIDAuthenticationFilter extends AbstractAuthenticationProcessing
|
|||
sb.append("?");
|
||||
isFirst = false;
|
||||
}
|
||||
sb.append(URLEncoder.encode(name, "UTF-8")).append("=").append(URLEncoder.encode(value, "UTF-8"));
|
||||
sb.append(utf8UrlEncode(name)).append("=").append(utf8UrlEncode(value));
|
||||
|
||||
if (iterator.hasNext()) {
|
||||
sb.append("&");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
Error err = new AssertionError("The Java platform guarantees UTF-8 support, but it seemingly is not present.");
|
||||
err.initCause(e);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -276,4 +270,20 @@ public class OpenIDAuthenticationFilter extends AbstractAuthenticationProcessing
|
|||
Assert.notNull(returnToUrlParameters, "returnToUrlParameters cannot be null");
|
||||
this.returnToUrlParameters = returnToUrlParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs URL encoding with UTF-8
|
||||
*
|
||||
* @param value the value to URL encode
|
||||
* @return the encoded value
|
||||
*/
|
||||
private String utf8UrlEncode(String value) {
|
||||
try {
|
||||
return URLEncoder.encode(value, "UTF-8");
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
Error err = new AssertionError("The Java platform guarantees UTF-8 support, but it seemingly is not present.");
|
||||
err.initCause(e);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue