Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Prevent url encoding for controller and action #276

Closed
wants to merge 2 commits into from

3 participants

mckenfra Jeff Scott Brown Jonathan Pearlin
mckenfra

Currently, the controller name and action name are url-encoded when creating an HTML link.

But I want to be able to configure my controller to have a featureUri with a slash in it - e.g. "admin/myController". This should be possible using the UrlMappings framework, but currently fails because the slash is encoded to "%2F" by the LinkGenerator. So the URI becomes "admin%2FmyController".

This patch prevents URL-encoding the controller name and action, when creating a URL.

mckenfra added some commits
mckenfra mckenfra Prevent url encoding for controller and action
Currently, the controller name and action name are url-encoded when creating an HTML link.
But I want to be able to configure my controller to have a featureUri with a slash in it - e.g. "admin/myController". This should be possible using the UrlMappings framework, but currently fails because the slash is encoded to "%2F" by the LinkGenerator. So the URI becomes "admin%2FmyController".
This patch prevents URL-encoding the controller name and action, when creating a URL.
04b45ca
mckenfra mckenfra Prevent url encoding for controller and action
Currently, the controller name and action name are url-encoded when creating an HTML link.
But I want to be able to configure my controller to have a featureUri with a slash in it - e.g. "admin/myController". This should be possible using the UrlMappings framework, but currently fails because the slash is encoded to "%2F" by the LinkGenerator. So the URI becomes "admin%2FmyController".
This patch prevents URL-encoding the controller name and action, when creating a URL.
ec28a8c
Jeff Scott Brown
Owner

Do you have any relevant unit tests?

mckenfra
mckenfra
Jonathan Pearlin

That was my mistake. I didn't notice the second commit in the patch where you fixed the issue. Comment happily withdrawn :).

mckenfra
mckenfra mckenfra closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 27, 2012
  1. mckenfra

    Prevent url encoding for controller and action

    mckenfra authored
    Currently, the controller name and action name are url-encoded when creating an HTML link.
    But I want to be able to configure my controller to have a featureUri with a slash in it - e.g. "admin/myController". This should be possible using the UrlMappings framework, but currently fails because the slash is encoded to "%2F" by the LinkGenerator. So the URI becomes "admin%2FmyController".
    This patch prevents URL-encoding the controller name and action, when creating a URL.
  2. mckenfra

    Prevent url encoding for controller and action

    mckenfra authored
    Currently, the controller name and action name are url-encoded when creating an HTML link.
    But I want to be able to configure my controller to have a featureUri with a slash in it - e.g. "admin/myController". This should be possible using the UrlMappings framework, but currently fails because the slash is encoded to "%2F" by the LinkGenerator. So the URI becomes "admin%2FmyController".
    This patch prevents URL-encoding the controller name and action, when creating a URL.
This page is out of date. Refresh to see the latest.
19 grails-plugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlCreator.java
View
@@ -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);
@@ -240,9 +240,18 @@ 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);
}
}
Something went wrong with that request. Please try again.