Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
JCR Resource 2.0.6
-
None
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