Uploaded image for project: 'XMLGraphicsCommons'
  1. XMLGraphicsCommons
  2. XGC-131

[PATCH] UnrestrictedFallbackResolver opens input stream for wrong resource

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.7, 2.8
    • None
    • general
    • None
    • Patch

    Description

      There is a bug in UnrestrictedFallbackResolver (an embedded class in AbstractImageSessionContext) which causes it to open an input stream for the wrong resource (the Source) instead of the uri of the image passed to createSource(...).

      This happens whenever the systemId in the Source starts with file:. Instead of opening a FileInputStream for the image referenced by uri, a stream for the URI in the Source's systemId is opened.

      I discovered this because FOP is unable to include images in a PDF in one of our applications. Instead of reading the image file, it tries to use the FOP document as an image. I was able to avoid this problem on the FOP level by using EnvironmentalProfileFactory.createRestrictedIO(...), which switches to the RestricedFallbackResolver which does not have the problem.

      A patch for AbstractImageSessionContext.java is attached (xmlgraphics-commons-patch-1.txt).

      Also attached is a Zip file countaining a Maven project (test-unrestricted-fallback-resolver.zip). Running mvn test on this project will run 6 unit tests, repeating the same tests 3 times to show the different behaviour between

      • UnrestrictedFallbackResolver (where the test recreating the conditions described above fails)
      • RestricedFallbackResolver
      • a class containing the patched version of UnrestrictedFallbackResolver

      Attachments

        1. test-unrestricted-fallback-resolver.zip
          7 kB
          Peter Schlömer
        2. xmlgraphics-commons-patch-1.txt
          1 kB
          Peter Schlömer

        Activity

          People

            Unassigned Unassigned
            PeterSchloemer Peter Schlömer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: