You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Alexander Klimetschek (JIRA)" <ji...@apache.org> on 2010/12/17 14:31:02 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=12972481#action_12972481 ] 

Alexander Klimetschek commented on SLING-1899:
----------------------------------------------

> 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 disagree. Because then you need another utility method in your application to url-encode the resulting string. Such a "basic" thing should be done by the Sling API to be able to do things like this in a jsp, for example:

<a href="<%= resourceResolver.map(repoPath) %>">link</a>

It is true that the resource resolution does not url-decode the URL since it has already been done by the servlet engine, however, on the way back, there is nothing that would do the url-encoding automatically, since a servlet directly writes to the response.

I think the case were you want a not-url-encoded string back from the map() method is rarer.

> 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_mapresolv_specialchars_fix.patch, 101216_mapresolve_specialchars_test.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.
-
You can reply to this email to add a comment to the issue online.