mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-24 04:52:16 +00:00
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.
|
* @return The <tt>return_to</tt> URL.
|
||||||
*/
|
*/
|
||||||
protected String buildReturnToUrl(HttpServletRequest request) {
|
protected String buildReturnToUrl(HttpServletRequest request) {
|
||||||
try {
|
|
||||||
StringBuffer sb = request.getRequestURL();
|
StringBuffer sb = request.getRequestURL();
|
||||||
|
|
||||||
Iterator<String> iterator = returnToUrlParameters.iterator();
|
Iterator<String> iterator = returnToUrlParameters.iterator();
|
||||||
@ -207,18 +206,13 @@ public class OpenIDAuthenticationFilter extends AbstractAuthenticationProcessing
|
|||||||
sb.append("?");
|
sb.append("?");
|
||||||
isFirst = false;
|
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()) {
|
if (iterator.hasNext()) {
|
||||||
sb.append("&");
|
sb.append("&");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.toString();
|
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");
|
Assert.notNull(returnToUrlParameters, "returnToUrlParameters cannot be null");
|
||||||
this.returnToUrlParameters = returnToUrlParameters;
|
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…
x
Reference in New Issue
Block a user