You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by "Michael Kainzbauer (Jira)" <ji...@apache.org> on 2021/12/01 14:50:00 UTC
[jira] [Updated] (FOP-3036) InternaResourceResolver fails on schemes starting with "data"
[ https://issues.apache.org/jira/browse/FOP-3036?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Kainzbauer updated FOP-3036:
------------------------------------
Description:
org.apache.fop.apps.io.InternalResourceResolver seems to check for "DataURIs" in a wrong way:
{{public Resource getResource(String stringUri) throws IOException, URISyntaxException {}}
{{return *{color:#ff0000}s{color}{color:#ff0000}tringUri.startsWith("data:"){color}* ? new Resource(this.resolveDataURI(stringUri)) : this.{color:#57d9a3}getResource{color}(cleanURI(stringUri));}}
{{}}}
{{public Resource {color:#57d9a3}getResource{color}(URI uri) throws IOException {}}
{{return uri.getScheme() != null && *{color:#ff0000}uri.getScheme().startsWith("data"){color}* ? new Resource(this.resolveDataURI(uri.toASCIIString())) : this.resourceResolver.getResource(this.resolveFromBase(uri));}}
{{}}}
The first check in Method {{{}public Resource getResource(String stringUri){}}}, if the stringUri starts with "data:" is correct: any URIs with, an only with, the scheme "data" will be resolved with the resolveDataURI method.
Example:
* resolving an URI with scheme "data" will be resolved with the resolveDataURI method
* resolving an URI with scheme "datamatrix" will be delegated to {{public Resource {color:#57d9a3}getResource{color}(URI uri) method.}}
* resolving an URI with scheme "foo" will be delegated to {{public Resource {color:#57d9a3}getResource{color}(URI uri) method.}}
The second check in {{{}public Resource {color:#57d9a3}getResource{color}(URI uri){}}}, if the scheme starts with data is wrong: any URIs with a scheme starting with"data" will be resolved with the resolveDataURI method.
Example:
* resolving an URI with scheme "data" will be resolved with the resolveDataURI method
* {{resolving an URI with scheme "datamatrix" will be resolved with the resolveDataURI method, which is wrong, should be handled by this.resourceResolver.getResource(this.resolveFromBase(uri)}}
* {{resolving an URI with scheme "foo" will be handled by this.resourceResolver.getResource(this.resolveFromBase(uri)}}
The second method should be:
{{public Resource {color:#57d9a3}getResource{color}(URI uri) throws IOException {}}
{{return uri.getScheme() != null && *{color:#ff0000}uri.getScheme().{color:#57d9a3}equals{color}{color}{color:#de350b}("data"){color}* ? new Resource(this.resolveDataURI(uri.toASCIIString())) : this.resourceResolver.getResource(this.resolveFromBase(uri));}}
{{}}}
was:
org.apache.fop.apps.io.InternalResourceResolver seems to check for "DataURIs" in a wrong way:
{{public Resource getResource(String stringUri) throws IOException, URISyntaxException {}}
{{return *{color:#ff0000}s{color}{color:#ff0000}tringUri.startsWith("data:"){color}* ? new Resource(this.resolveDataURI(stringUri)) : this.{color:#57d9a3}getResource{color}(cleanURI(stringUri));}}
{{}}}
{{public Resource {color:#57d9a3}getResource{color}(URI uri) throws IOException {}}
{{return uri.getScheme() != null && *{color:#ff0000}uri.getScheme().startsWith("data"){color}* ? new Resource(this.resolveDataURI(uri.toASCIIString())) : this.resourceResolver.getResource(this.resolveFromBase(uri));}}
{{}}}
The first check in Method {{{}public Resource getResource(String stringUri){}}}, if the stringUri starts with "data:" is correct: any URIs with, an only with, the scheme "data" will be resolved with the resolveDataURI method.
Example:
* resolving an URI with scheme "data" will be resolved with the resolveDataURI method
* resolving an URI with scheme "datamatrix" will be delegated to {{public Resource {color:#57d9a3}getResource{color}(URI uri) method.}}
* resolving an URI with scheme "foo" will be delegated to {{public Resource {color:#57d9a3}getResource{color}(URI uri) method.}}
The second check in {{{}public Resource {color:#57d9a3}getResource{color}(URI uri){}}}, if the scheme starts with data is wrong: any URIs with a scheme starting with"data" will be resolved with the resolveDataURI method.
Example:
* resolving an URI with scheme "data" will be resolved with the resolveDataURI method
* {{resolving an URI with scheme "datamatrix" will be resolved with the resolveDataURI method, which is wrong, should be handled by this.resourceResolver.getResource(this.resolveFromBase(uri)}}
* {{resolving an URI with scheme "foo" will be handled by this.resourceResolver.getResource(this.resolveFromBase(uri)}}
The second method should be:
{{public Resource {color:#57d9a3}getResource{color}(URI uri) throws IOException {}}
{{return uri.getScheme() != null && *{color:#ff0000}uri.getScheme().{color:#57d9a3}equals{color}("data"){color}* ? new Resource(this.resolveDataURI(uri.toASCIIString())) : this.resourceResolver.getResource(this.resolveFromBase(uri));}}
{{}}}
> InternaResourceResolver fails on schemes starting with "data"
> -------------------------------------------------------------
>
> Key: FOP-3036
> URL: https://issues.apache.org/jira/browse/FOP-3036
> Project: FOP
> Issue Type: Bug
> Components: unqualified
> Affects Versions: 2.6
> Reporter: Michael Kainzbauer
> Priority: Major
>
> org.apache.fop.apps.io.InternalResourceResolver seems to check for "DataURIs" in a wrong way:
>
> {{public Resource getResource(String stringUri) throws IOException, URISyntaxException {}}
> {{return *{color:#ff0000}s{color}{color:#ff0000}tringUri.startsWith("data:"){color}* ? new Resource(this.resolveDataURI(stringUri)) : this.{color:#57d9a3}getResource{color}(cleanURI(stringUri));}}
> {{}}}
> {{public Resource {color:#57d9a3}getResource{color}(URI uri) throws IOException {}}
> {{return uri.getScheme() != null && *{color:#ff0000}uri.getScheme().startsWith("data"){color}* ? new Resource(this.resolveDataURI(uri.toASCIIString())) : this.resourceResolver.getResource(this.resolveFromBase(uri));}}
> {{}}}
> The first check in Method {{{}public Resource getResource(String stringUri){}}}, if the stringUri starts with "data:" is correct: any URIs with, an only with, the scheme "data" will be resolved with the resolveDataURI method.
> Example:
> * resolving an URI with scheme "data" will be resolved with the resolveDataURI method
> * resolving an URI with scheme "datamatrix" will be delegated to {{public Resource {color:#57d9a3}getResource{color}(URI uri) method.}}
> * resolving an URI with scheme "foo" will be delegated to {{public Resource {color:#57d9a3}getResource{color}(URI uri) method.}}
>
> The second check in {{{}public Resource {color:#57d9a3}getResource{color}(URI uri){}}}, if the scheme starts with data is wrong: any URIs with a scheme starting with"data" will be resolved with the resolveDataURI method.
> Example:
> * resolving an URI with scheme "data" will be resolved with the resolveDataURI method
> * {{resolving an URI with scheme "datamatrix" will be resolved with the resolveDataURI method, which is wrong, should be handled by this.resourceResolver.getResource(this.resolveFromBase(uri)}}
> * {{resolving an URI with scheme "foo" will be handled by this.resourceResolver.getResource(this.resolveFromBase(uri)}}
>
> The second method should be:
> {{public Resource {color:#57d9a3}getResource{color}(URI uri) throws IOException {}}
> {{return uri.getScheme() != null && *{color:#ff0000}uri.getScheme().{color:#57d9a3}equals{color}{color}{color:#de350b}("data"){color}* ? new Resource(this.resolveDataURI(uri.toASCIIString())) : this.resourceResolver.getResource(this.resolveFromBase(uri));}}
> {{}}}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)