You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ace.apache.org by "Bram de Kruijff (JIRA)" <ji...@apache.org> on 2011/07/28 23:58:09 UTC
[jira] [Created] (ACE-160) REST client interface URI encoding
problem with spaces
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
[jira] [Commented] (ACE-160) REST client interface URI encoding
problem with spaces
Posted by "Marcel Offermans (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/ACE-160?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13072592#comment-13072592 ]
Marcel Offermans commented on ACE-160:
--------------------------------------
The methods "buildPathFromElements" and "getPathElements" should remain symmetrical, so I'm going to apply this patch plus some more, and I'll add a test to validate this behaviour.
> 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
> Assignee: Marcel Offermans
>
> 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
[jira] [Assigned] (ACE-160) REST client interface URI encoding
problem with spaces
Posted by "Marcel Offermans (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/ACE-160?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Marcel Offermans reassigned ACE-160:
------------------------------------
Assignee: 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
> Assignee: Marcel Offermans
>
> 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
[jira] [Resolved] (ACE-160) REST client interface URI encoding
problem with spaces
Posted by "Marcel Offermans (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/ACE-160?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Marcel Offermans resolved ACE-160.
----------------------------------
Resolution: Fixed
Committed patch and test.
> 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
> Assignee: Marcel Offermans
>
> 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