You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by "J.W. Janssen (JIRA)" <ji...@apache.org> on 2012/08/14 10:53:38 UTC
[jira] [Closed] (ACE-160) REST client interface URI encoding
problem with spaces
[ https://issues.apache.org/jira/browse/ACE-160?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
J.W. Janssen closed ACE-160.
----------------------------
Assignee: (was: Marcel Offermans)
> REST client interface URI encoding problem with spaces
> -------------------------------------------------------
>
> Key: ACE-160
> URL: https://issues.apache.org/jira/browse/ACE-160
> Project: ACE
> Issue Type: Bug
> Affects Versions: 0.8.0
> Reporter: Bram de Kruijff
>
> RESTClientServlet uses URLEncoder.encode(..) on resource identifiers. This is ok most of the time, but breaks a client when there is a space in the association filter used used as part the identifier. Eg. Features and distributions use the name attribute in the association filter, so when one creates a feature with a space in the name "My Feature" the filter be something like (&(name=My Feature)).
> The problem...
> URLEncoder.encode(...) encodes into application/x-www-form-urlencoded which is ok for a querystring, not for a URI.
> What happens...
> 1. URLEncoder.encode(..) will translated "My Feature" into "My+Feature"
> 2. When a client (eg perl) uir_decodes this the result will still be "My+Feature"
> 3. Using this as identifier in for example an association will fail.
> My workaround...
> Index: ace-client-rest/src/main/java/org/apache/ace/client/rest/RESTClientServlet.java
> ===================================================================
> --- ace-client-rest/src/main/java/org/apache/ace/client/rest/RESTClientServlet.java (revision 1150996)
> +++ ace-client-rest/src/main/java/org/apache/ace/client/rest/RESTClientServlet.java (working copy)
> @@ -295,7 +295,8 @@
> result.append('/');
> }
> try {
> - result.append(URLEncoder.encode(element, "UTF-8"));
> + //URL Encode is not for path
> + result.append(URLEncoder.encode(element, "UTF-8").replaceAll("\\+", "%20"));
> }
> catch (UnsupportedEncodingException e) {} // ignored on purpose, any JVM must support UTF-8
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira