[ https://issues.apache.org/jira/browse/SLING-1218?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexander Klimetschek updated SLING-1218: ----------------------------------------- Description: The JcrResourceResolver's map() methods do not escape the URIs that are returned (as string). For example, a path with spaces (which is valid in JCR) such as /content/path/with spaces.jpg will be returned as-is (or like "http://my.domain.com/content/path/with spaces.jpg" if a mapping config is present for that). However, it should be returned as /content/path/with%20spaces.jpg (Or in case of a mapping config, like "http://my.domain.com/content/path/with%20spaces.jpg"). Furthermore, in case of a mapping config present, an URISyntaxException exception will be thrown in line 384 of JcrResourceResolver as the uri string "mappedPath" contains spaces and cannot be parsed by java.net.URI(String), which expects an already-escaped URI. That exception is catched internally, but namespace mangling and prepending of the servlet context path are omitted in that case. The use of java.net.URI is not good when it is about building URIs from plain, unescaped components, since it only really supports parsing of escaped uri strings and the multi-args constructor in conjunction with toString() simply behaves wrong. See also http://blog.limewire.org/?p=261 was: The JcrResourceResolver's map() methods do not escape the URIs that are returned (as string). For example, a path with spaces (which is valid in JCR) such as /content/path/with spaces.jpg will be returned as-is (or like http://my.domain.com/content/path/with spaces.jpg if a mapping config is present for that). However, it should be returned as http://localhost:4502/content/dam/geometrixx/portraits/chris%20stark.jpg Furthermore, in case of a mapping config present, an URISyntaxException exception will be thrown in line 384 of JcrResourceResolver as the uri string "mappedPath" contains spaces and cannot be parsed by java.net.URI(String), which expects an already-escaped URI. That exception is catched internally, but namespace mangling and prepending of the servlet context path are omitted in that case. The use of java.net.URI is not good when it is about building URIs from plain, unescaped components, since it only really supports parsing of escaped uri strings and the multi-args constructor in conjunction with toString() simply behaves wrong. See also http://blog.limewire.org/?p=261 > JcrResourceResolver.map() does not return proper escaped URIs > ------------------------------------------------------------- > > Key: SLING-1218 > URL: https://issues.apache.org/jira/browse/SLING-1218 > Project: Sling > Issue Type: Bug > Components: JCR > Affects Versions: JCR Resource 2.0.6 > Reporter: Alexander Klimetschek > > The JcrResourceResolver's map() methods do not escape the URIs that are > returned (as string). For example, a path with spaces (which is valid in JCR) > such as > /content/path/with spaces.jpg > will be returned as-is (or like "http://my.domain.com/content/path/with > spaces.jpg" if a mapping config is present for that). However, it should be > returned as > /content/path/with%20spaces.jpg > (Or in case of a mapping config, like > "http://my.domain.com/content/path/with%20spaces.jpg"). > Furthermore, in case of a mapping config present, an URISyntaxException > exception will be thrown in line 384 of JcrResourceResolver as the uri string > "mappedPath" contains spaces and cannot be parsed by java.net.URI(String), > which expects an already-escaped URI. That exception is catched internally, > but namespace mangling and prepending of the servlet context path are omitted > in that case. > The use of java.net.URI is not good when it is about building URIs from > plain, unescaped components, since it only really supports parsing of escaped > uri strings and the multi-args constructor in conjunction with toString() > simply behaves wrong. See also http://blog.limewire.org/?p=261 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.