You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Ian Boston (JIRA)" <ji...@apache.org> on 2013/02/15 07:41:12 UTC

[jira] [Commented] (SLING-1899) JcrResourceResolver map method is not reverse operation of resolve method with special chars in path

    [ https://issues.apache.org/jira/browse/SLING-1899?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13578993#comment-13578993 ] 

Ian Boston commented on SLING-1899:
-----------------------------------

I started trying to implement the new method here, and found there was a subtlety that might make changing the current behaviour wrong.
Its possible that ResourceResolverImpl.map has evolved since this issue was created.

The current ResourceResolverImpl contains code to handle a query string. The parameters of the query string must be URL encoded, which means the path must also be url encoded. 

It could be made to return a non url encoded path, and a url encoded query string, but the caller would have to split the two apart before encoding

eg a parameter called withequals is "With=In a parameter" becomes a query string of space=With%3DIn%20a%20parameter

Leaving it un URL encoded is wrong "space=With=In a parameter"

URL encoding just the query string is wrong
/test= ing/a?space=With%3DIn%20a%20parameter

since the caller will have to split the query string off to encode and avoid double encoding the query string.
/test%3D%20ing/a?space%3DWith%253DIn%2520a%2520parameter

So there are two options left:

Create a method that strips the query string during the map operation making its behaviour different from map(...)
Or
Do nothing and avoid inconsistent duplicate behaviour.

I think leave as is and close this wont-fix. WDYT?
(or did I miss something)

 
                
> JcrResourceResolver map method is not reverse operation of resolve method with special chars in path
> ----------------------------------------------------------------------------------------------------
>
>                 Key: SLING-1899
>                 URL: https://issues.apache.org/jira/browse/SLING-1899
>             Project: Sling
>          Issue Type: Bug
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.6
>            Reporter: Stefan Seifert
>         Attachments: 101216_mapresolve_specialchars_test.patch, 101216_mapresolv_specialchars_fix.patch
>
>
> according to the javadocs of the ResourceResolver API interface, the map method is intended as the reverse operation of the resolve method.
> this is not the case if the path contains special chars like spaces - they are url-encoded, although the javadocs of the API does not require this.
> additionally the resolve method does not url-decode the path (which is correct in my opinion because the servlet engine already decodes the path).
> the map method should be fixed, so that not url-encoding takes place in it. the application is responsible for url-encoding a path if needed, not the sling api.
> i've attached a patch which contains a simple unit tests that makes the current implementation fail when resolving a path generated with the map method: [^101216_mapresolve_specialchars_test.patch]

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira