[jira] [Commented] (FOP-2861) Allow resource loading from jar: URI

2021-10-31 Thread David Shepherdson (Jira)


[ 
https://issues.apache.org/jira/browse/FOP-2861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17436555#comment-17436555
 ] 

David Shepherdson commented on FOP-2861:


Unfortunately it seems that the original attached patch has a slight bug in it: 
by using {{getRawSchemeSpecificPart()}}, it ends up double-encoding any 
already-encoded characters in the base URI (for example, if there are spaces in 
the path to the JAR file). Switching this to {{getSchemeSpecificPart()}} 
instead fixes the problem, since then the encoded/decoded state of the strings 
matches what the {{URI}} constructor arguments expect. I've attached this 
tweaked version here as  [^uri_resolve_decoded.diff].

> Allow resource loading from jar: URI
> 
>
> Key: FOP-2861
> URL: https://issues.apache.org/jira/browse/FOP-2861
> Project: FOP
>  Issue Type: Improvement
>Affects Versions: 2.0, 2.1, 2.2, 2.3, 2.4, 2.6
>Reporter: Ole Sandum
>Priority: Major
> Attachments: FopResourceResolver.java, uri_resolve.diff, 
> uri_resolve_decoded.diff
>
>
> We would like to load our FOP config.xml along with related fonts and 
> hyphenation files using  the common classloader URL, e.g.:
> {{  URL configXml = getClass().getResource("config.xml");}}
> {{  FopConfParser confParser = }}
> {{      new FopConfParser(configXml.openStream(), configXml.toURI());}}
> This makes for easy deployment, and works nicely as long as classes and 
> resources are loaded from separate files, i.e. from 
> file:/some/path/config.xml URIs. However, it fails when classes and resources 
> are packaged and loaded directly from a jar, i.e. from 
> jar:file:/some/archive.jar!/path/config.xml URIs, as is the case when 
> deploying with JWS or running an all-in-one executable jar, as it will fail 
> to properly resolve the related font and hyphenation file URIs. 
> See [https://github.com/osandum/fop-test.git] for a test to illustrate.
> This is a consequence of a long standing issue (reported in 
> [https://bugs.openjdk.java.net/browse/JDK-8020755)] that 
> URI.resolve(childUri) doesn't work as expected on jar:file: URIs.
> In this case, it can be easily remedied by a work-around to the call in 
> InternalResourceResolver.resolveFromBase(URI uri). Patch attached.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (FOP-2861) Allow resource loading from jar: URI

2021-10-31 Thread David Shepherdson (Jira)


 [ 
https://issues.apache.org/jira/browse/FOP-2861?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

David Shepherdson updated FOP-2861:
---
Attachment: uri_resolve_decoded.diff

> Allow resource loading from jar: URI
> 
>
> Key: FOP-2861
> URL: https://issues.apache.org/jira/browse/FOP-2861
> Project: FOP
>  Issue Type: Improvement
>Affects Versions: 2.0, 2.1, 2.2, 2.3, 2.4, 2.6
>Reporter: Ole Sandum
>Priority: Major
> Attachments: FopResourceResolver.java, uri_resolve.diff, 
> uri_resolve_decoded.diff
>
>
> We would like to load our FOP config.xml along with related fonts and 
> hyphenation files using  the common classloader URL, e.g.:
> {{  URL configXml = getClass().getResource("config.xml");}}
> {{  FopConfParser confParser = }}
> {{      new FopConfParser(configXml.openStream(), configXml.toURI());}}
> This makes for easy deployment, and works nicely as long as classes and 
> resources are loaded from separate files, i.e. from 
> file:/some/path/config.xml URIs. However, it fails when classes and resources 
> are packaged and loaded directly from a jar, i.e. from 
> jar:file:/some/archive.jar!/path/config.xml URIs, as is the case when 
> deploying with JWS or running an all-in-one executable jar, as it will fail 
> to properly resolve the related font and hyphenation file URIs. 
> See [https://github.com/osandum/fop-test.git] for a test to illustrate.
> This is a consequence of a long standing issue (reported in 
> [https://bugs.openjdk.java.net/browse/JDK-8020755)] that 
> URI.resolve(childUri) doesn't work as expected on jar:file: URIs.
> In this case, it can be easily remedied by a work-around to the call in 
> InternalResourceResolver.resolveFromBase(URI uri). Patch attached.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)