Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-3036

InternaResourceResolver fails on schemes starting with "data"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 2.6
    • None
    • unqualified
    • None

    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 stringUri.startsWith("data:") ? new Resource(this.resolveDataURI(stringUri)) : this.getResource(cleanURI(stringUri));
      }

      public Resource getResource(URI uri) throws IOException {
      return uri.getScheme() != null && uri.getScheme().startsWith("data") ? 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 getResource(URI uri) method.
      • resolving an URI with scheme "foo" will be delegated to public Resource getResource(URI uri) method.

       

      The second check in public Resource getResource(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 getResource(URI uri) throws IOException {
      return uri.getScheme() != null && uri.getScheme().equals("data") ? new Resource(this.resolveDataURI(uri.toASCIIString())) : this.resourceResolver.getResource(this.resolveFromBase(uri));
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            mkainzbauer Michael Kainzbauer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: