You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xmlgraphics.apache.org by "Peter Schlömer (Jira)" <ji...@apache.org> on 2022/09/26 10:47:00 UTC

[jira] [Created] (XGC-131) UnrestrictedFallbackResolver opens input stream for wrong resource

Peter Schlömer created XGC-131:
----------------------------------

             Summary: UnrestrictedFallbackResolver opens input stream for wrong resource
                 Key: XGC-131
                 URL: https://issues.apache.org/jira/browse/XGC-131
             Project: XMLGraphicsCommons
          Issue Type: Bug
          Components: general
    Affects Versions: 2.7, trunk
            Reporter: Peter Schlömer
         Attachments: test-unrestricted-fallback-resolver.zip, xmlgraphics-commons-patch-1.txt

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}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org