[jira] [Commented] (BATIK-1090) Embedded SVG reports "Content is not allowed in prolog"

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[jira] [Commented] (BATIK-1090) Embedded SVG reports "Content is not allowed in prolog"

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/BATIK-1090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15931299#comment-15931299 ]

Hussein Shafie commented on BATIK-1090:
---------------------------------------

The following patch seems to fix the issue.

Modified sources/org/apache/batik/util/ParsedURLDataProtocolHandler.java as follows:
===============================================================
--- ParsedURLDataProtocolHandler.java.ORI 2015-03-06 10:57:01.000000000 +0100
+++ ParsedURLDataProtocolHandler.java 2017-03-18 18:00:26.190975076 +0100
@@ -43,8 +43,16 @@
     }
 
     public ParsedURLData parseURL(ParsedURL baseURL, String urlStr) {
-        // No relative form...
-        return parseURL(urlStr);
+        if (urlStr != null && urlStr.startsWith("#") &&
+            baseURL != null && "data".equals(baseURL.data.protocol)) {
+            // No relative form per se. Just record this ref in a copy of the
+            // base DataParsedURLData.
+            DataParsedURLData ret = ((DataParsedURLData) baseURL.data).copy();
+            ret.ref = urlStr.substring(1);
+            return ret;
+        } else {
+            return parseURL(urlStr);
+        }
     }
 
     public ParsedURLData parseURL(String urlStr) {
@@ -129,6 +137,21 @@
 
         String charset;
 
+        public DataParsedURLData copy() {
+            DataParsedURLData copy = new DataParsedURLData();
+
+            copy.protocol = protocol;
+            copy.host = host;
+            copy.port = port;
+            copy.path = path;
+            copy.ref = ref;
+            copy.contentType = contentType;
+            copy.contentEncoding = contentEncoding;
+            copy.charset = charset;
+
+            return copy;
+        }
+
         public boolean complete() {
             return path != null;
         }
===============================================================


> Embedded SVG reports "Content is not allowed in prolog"
> -------------------------------------------------------
>
>                 Key: BATIK-1090
>                 URL: https://issues.apache.org/jira/browse/BATIK-1090
>             Project: Batik
>          Issue Type: Bug
>          Components: Bridge, SVG Rasterizer
>    Affects Versions: 1.7, 1.8
>         Environment: Both Ubuntu and OS X Yosemite
>            Reporter: Simon Sotak
>         Attachments: inner.svg, outer.svg
>
>
> I have the following svg:
> https://dl.dropboxusercontent.com/u/73774/svg/outer.svg
> When I try to rasterize it with Batik, I get the exception
> {code:borderStyle=solid}
> org.apache.batik.bridge.BridgeException: Content is not allowed in prolog.
> at org.apache.batik.bridge.BridgeContext.getReferencedNode(BridgeContext.java:780)
> at org.apache.batik.bridge.BridgeContext.getReferencedElement(BridgeContext.java:796)
> at org.apache.batik.bridge.CSSUtilities.convertClipPath(CSSUtilities.java:719)
> at org.apache.batik.bridge.AbstractGraphicsNodeBridge.buildGraphicsNode(AbstractGraphicsNodeBridge.java:146)
> at org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(SVGShapeElementBridge.java:92)
> at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:224)
> at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
> at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:219)
> at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
> at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:219)
> at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
> at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:219)
> at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
> at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:219)
> at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
> at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:141)
> at org.apache.batik.bridge.SVGImageElementBridge.createSVGImageNode(SVGImageElementBridge.java:660)
> at org.apache.batik.bridge.SVGImageElementBridge.createImageGraphicsNode(SVGImageElementBridge.java:288)
> at org.apache.batik.bridge.SVGImageElementBridge.buildImageGraphicsNode(SVGImageElementBridge.java:177)
> at org.apache.batik.bridge.SVGImageElementBridge.createGraphicsNode(SVGImageElementBridge.java:119)
> at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:213)
> at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
> at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:219)
> at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
> at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:219)
> at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
> at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82)
> at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:208)
> at org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:92)
> at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142)
> at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156)
> at <my_code>
> Exception in thread "Animation Thread" org.apache.batik.transcoder.TranscoderException: null
> Enclosed Exception:
> Content is not allowed in prolog.
> at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:227)
> at org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:92)
> at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142)
> at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156)
> at <my_code>
> {code}
> I tried decoding the embedded base64 SVG, and batik rasterized it correctly.
> Here it is: https://dl.dropboxusercontent.com/u/73774/svg/inner.svg
> I tried inspecting the issue a bit, and the problem seems to be that the URLs in the embedded SVG that are in the form {{url(#SVGID_6_)}} are transformed to the form {{data:,#SVGID_6_}} which seems to cause the problem.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...