Prevent url encoding for controller and action #276

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+14 −5
Split
@@ -87,13 +87,13 @@ private String createURLWithWebRequest(Map parameterValues, GrailsWebRequest web
}
else {
if (controllerName != null) {
- appendUrlToken(actualUriBuf, controllerName, encoding);
+ appendUrlToken(actualUriBuf, controllerName, encoding, false);
}
else {
- appendUrlToken(actualUriBuf, requestStateLookupStrategy.getControllerName(), encoding);
+ appendUrlToken(actualUriBuf, requestStateLookupStrategy.getControllerName(), encoding, false);
}
}
- appendUrlToken(actualUriBuf, actionName, encoding);
+ appendUrlToken(actualUriBuf, actionName, encoding, false);
}
if (id != null) {
appendUrlToken(actualUriBuf, id, encoding);
@@ -239,10 +239,19 @@ private String urlEncode(Object obj, String charset) {
}
}
+ /*
+ * Appends a URL token to the buffer. Always url encodes the token before append.
+ */
+ protected void appendUrlToken(FastStringWriter actualUriBuf, Object token, String charset) {
+ appendUrlToken(actualUriBuf, token, charset, true);
+ }
+
/*
* Appends a URL token to the buffer
+ *
+ * @param needsUrlEncode If true, url encodes the token before append
*/
- private void appendUrlToken(FastStringWriter actualUriBuf, Object token, String charset) {
- actualUriBuf.append(SLASH).append(urlEncode(token, charset));
+ protected void appendUrlToken(FastStringWriter actualUriBuf, Object token, String charset, boolean needsUrlEncode) {
+ actualUriBuf.append(SLASH).append(needsUrlEncode ? urlEncode(token, charset) : token);
}
}