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.
For more information on JIRA, see: http://www.atlassian.com/software/jira