[ 
https://issues.apache.org/jira/browse/BATIK-1390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dennis Hendriks updated BATIK-1390:
-----------------------------------
    Description: 
If I have an SVG image with a 'stroke-width:-3' in the 'style' attribute of an 
element, errors for it are not properly reported. I found at two different 
scenarios where this is not properly reported, which are wrong for different 
reasons:

1. If I invoke 'builder.build(bridgeContext, document);', I get:

{code}
java.lang.IllegalArgumentException: negative width
        at java.desktop/java.awt.BasicStroke.<init>(BasicStroke.java:194)
        at 
org.apache.batik.bridge.PaintServer.convertStroke(PaintServer.java:649)
        at 
org.apache.batik.bridge.SVGTextElementBridge.setBaseTextPaintInfo(SVGTextElementBridge.java:1911)
        at 
org.apache.batik.bridge.SVGTextElementBridge.getTextPaintInfo(SVGTextElementBridge.java:1893)
        at 
org.apache.batik.bridge.SVGTextElementBridge.addChildPaintAttributes(SVGTextElementBridge.java:1458)
        at 
org.apache.batik.bridge.SVGTextElementBridge.addPaintAttributes(SVGTextElementBridge.java:1441)
        at 
org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(SVGTextElementBridge.java:652)
t 
org.apache.batik.bridge.SVGTextElementBridge.buildGraphicsNode(SVGTextElementBridge.java:286)
        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.build(GVTBuilder.java:82)
        ...
{code}

However, the 'build' method should throw a 'BridgeException', as documented, 
and as also thrown for various other problems, like DOM errors.

2) If the original SVG image is OK, but I programmatically set the 
'stroke-width' to '-3', I get the following printed to stderr:

{code}
java.lang.IllegalArgumentException: negative width
        at java.desktop/java.awt.BasicStroke.<init>(BasicStroke.java:194)
        at 
org.apache.batik.bridge.PaintServer.convertStroke(PaintServer.java:649)
        at 
org.apache.batik.bridge.SVGTextElementBridge.setBaseTextPaintInfo(SVGTextElementBridge.java:1911)
        at 
org.apache.batik.bridge.SVGTextElementBridge.getTextPaintInfo(SVGTextElementBridge.java:1893)
        at 
org.apache.batik.bridge.SVGTextElementBridge.addChildPaintAttributes(SVGTextElementBridge.java:1458)
        at 
org.apache.batik.bridge.SVGTextElementBridge.addPaintAttributes(SVGTextElementBridge.java:1441)
        at 
org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(SVGTextElementBridge.java:652)
        at 
org.apache.batik.bridge.SVGTextElementBridge.handleCSSEngineEvent(SVGTextElementBridge.java:730)
        at 
org.apache.batik.bridge.SVGTextElementBridge$AbstractTextChildBridgeUpdateHandler.handleCSSEngineEvent(SVGTextElementBridge.java:2175)
        at 
org.apache.batik.bridge.BridgeContext$CSSPropertiesChangedListener.propertiesChanged(BridgeContext.java:1741)
        at 
org.apache.batik.css.engine.CSSEngine.firePropertiesChangedEvent(CSSEngine.java:1830)
        at 
org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2095)
        at 
org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2031)
        at 
org.apache.batik.css.engine.CSSEngine.inlineStyleAttributeUpdated(CSSEngine.java:1898)
        at 
org.apache.batik.css.engine.CSSEngine.handleAttrModified(CSSEngine.java:2319)
        at 
org.apache.batik.css.engine.CSSEngine$CSSNavigableDocumentHandler.attrModified(CSSEngine.java:2481)
        at 
org.apache.batik.anim.dom.SVGOMDocument$DOMAttrModifiedListenerWrapper.handleEvent(SVGOMDocument.java:679)
        at 
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:320)
        at 
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:362)
        at 
org.apache.batik.dom.events.EventSupport.dispatchEvent(EventSupport.java:273)
        at 
org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:1012)
        at 
org.apache.batik.dom.AbstractElement.fireDOMAttrModifiedEvent(AbstractElement.java:661)
        at 
org.apache.batik.anim.dom.AbstractElement.fireDOMAttrModifiedEvent(AbstractElement.java:118)
        at org.apache.batik.dom.AbstractAttr.setNodeValue(AbstractAttr.java:156)
        at org.apache.batik.dom.AbstractAttr.setValue(AbstractAttr.java:199)
        at 
org.apache.batik.dom.AbstractElement.setAttributeNS(AbstractElement.java:265)
        at 
org.apache.batik.anim.dom.SVGStylableElement$StyleDeclaration.propertyChanged(SVGStylableElement.java:729)
        at 
org.apache.batik.css.dom.CSSOMStyleDeclaration.setProperty(CSSOMStyleDeclaration.java:157)
        ...
{code}

This is due to the following code from 'EventSupport', which calls 
'printStackTrace' on the exception, rather than reporting it via the user 
agent: 
https://github.com/apache/xmlgraphics-batik/blob/dc3f248a141e035805b5d39585d40aabb6bfd010/batik-dom/src/main/java/org/apache/batik/dom/events/EventSupport.java#L336


  was:
If I have an SVG image with a 'stroke-width:-3' in the 'style' attribute of an 
element, errors for it are not properly reported. I found at two different 
scenarios where this is not properly reported, which are wrong for different 
reasons:

1. If I invoke 'builder.build(bridgeContext, document);', I get:

{code}
java.lang.IllegalArgumentException: negative width
        at java.desktop/java.awt.BasicStroke.<init>(BasicStroke.java:194)
        at 
org.apache.batik.bridge.PaintServer.convertStroke(PaintServer.java:649)
        at 
org.apache.batik.bridge.SVGTextElementBridge.setBaseTextPaintInfo(SVGTextElementBridge.java:1911)
        at 
org.apache.batik.bridge.SVGTextElementBridge.getTextPaintInfo(SVGTextElementBridge.java:1893)
        at 
org.apache.batik.bridge.SVGTextElementBridge.addChildPaintAttributes(SVGTextElementBridge.java:1458)
        at 
org.apache.batik.bridge.SVGTextElementBridge.addPaintAttributes(SVGTextElementBridge.java:1441)
        at 
org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(SVGTextElementBridge.java:652)
t 
org.apache.batik.bridge.SVGTextElementBridge.buildGraphicsNode(SVGTextElementBridge.java:286)
        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.build(GVTBuilder.java:82)
    ...
{code}

However, the 'build' method should throw a 'BridgeException', as documented, 
and as also thrown for various other problems, like DOM errors.

2) If the original SVG image is OK, but I programmatically set the 
'stroke-width' to '-3', I get the following printed to stderr:

{code}
java.lang.IllegalArgumentException: negative width
        at java.desktop/java.awt.BasicStroke.<init>(BasicStroke.java:194)
        at 
org.apache.batik.bridge.PaintServer.convertStroke(PaintServer.java:649)
        at 
org.apache.batik.bridge.SVGTextElementBridge.setBaseTextPaintInfo(SVGTextElementBridge.java:1911)
        at 
org.apache.batik.bridge.SVGTextElementBridge.getTextPaintInfo(SVGTextElementBridge.java:1893)
        at 
org.apache.batik.bridge.SVGTextElementBridge.addChildPaintAttributes(SVGTextElementBridge.java:1458)
        at 
org.apache.batik.bridge.SVGTextElementBridge.addPaintAttributes(SVGTextElementBridge.java:1441)
        at 
org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(SVGTextElementBridge.java:652)
        at 
org.apache.batik.bridge.SVGTextElementBridge.handleCSSEngineEvent(SVGTextElementBridge.java:730)
        at 
org.apache.batik.bridge.SVGTextElementBridge$AbstractTextChildBridgeUpdateHandler.handleCSSEngineEvent(SVGTextElementBridge.java:2175)
        at 
org.apache.batik.bridge.BridgeContext$CSSPropertiesChangedListener.propertiesChanged(BridgeContext.java:1741)
        at 
org.apache.batik.css.engine.CSSEngine.firePropertiesChangedEvent(CSSEngine.java:1830)
        at 
org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2095)
        at 
org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2031)
        at 
org.apache.batik.css.engine.CSSEngine.inlineStyleAttributeUpdated(CSSEngine.java:1898)
        at 
org.apache.batik.css.engine.CSSEngine.handleAttrModified(CSSEngine.java:2319)
        at 
org.apache.batik.css.engine.CSSEngine$CSSNavigableDocumentHandler.attrModified(CSSEngine.java:2481)
        at 
org.apache.batik.anim.dom.SVGOMDocument$DOMAttrModifiedListenerWrapper.handleEvent(SVGOMDocument.java:679)
        at 
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:320)
        at 
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:362)
        at 
org.apache.batik.dom.events.EventSupport.dispatchEvent(EventSupport.java:273)
        at 
org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:1012)
        at 
org.apache.batik.dom.AbstractElement.fireDOMAttrModifiedEvent(AbstractElement.java:661)
        at 
org.apache.batik.anim.dom.AbstractElement.fireDOMAttrModifiedEvent(AbstractElement.java:118)
        at org.apache.batik.dom.AbstractAttr.setNodeValue(AbstractAttr.java:156)
        at org.apache.batik.dom.AbstractAttr.setValue(AbstractAttr.java:199)
        at 
org.apache.batik.dom.AbstractElement.setAttributeNS(AbstractElement.java:265)
        at 
org.apache.batik.anim.dom.SVGStylableElement$StyleDeclaration.propertyChanged(SVGStylableElement.java:729)
        at 
org.apache.batik.css.dom.CSSOMStyleDeclaration.setProperty(CSSOMStyleDeclaration.java:157)
        ...
{code}

This is due to the following code from 'EventSupport', which calls 
'printStackTrace' on the exception, rather than reporting it via the user 
agent: 
https://github.com/apache/xmlgraphics-batik/blob/dc3f248a141e035805b5d39585d40aabb6bfd010/batik-dom/src/main/java/org/apache/batik/dom/events/EventSupport.java#L336



> IllegalArgumentException parsing negative 'stroke-width' is not properly 
> reported
> ---------------------------------------------------------------------------------
>
>                 Key: BATIK-1390
>                 URL: https://issues.apache.org/jira/browse/BATIK-1390
>             Project: Batik
>          Issue Type: Bug
>          Components: CSS
>            Reporter: Dennis Hendriks
>            Priority: Major
>
> If I have an SVG image with a 'stroke-width:-3' in the 'style' attribute of 
> an element, errors for it are not properly reported. I found at two different 
> scenarios where this is not properly reported, which are wrong for different 
> reasons:
> 1. If I invoke 'builder.build(bridgeContext, document);', I get:
> {code}
> java.lang.IllegalArgumentException: negative width
>       at java.desktop/java.awt.BasicStroke.<init>(BasicStroke.java:194)
>       at 
> org.apache.batik.bridge.PaintServer.convertStroke(PaintServer.java:649)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.setBaseTextPaintInfo(SVGTextElementBridge.java:1911)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.getTextPaintInfo(SVGTextElementBridge.java:1893)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.addChildPaintAttributes(SVGTextElementBridge.java:1458)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.addPaintAttributes(SVGTextElementBridge.java:1441)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(SVGTextElementBridge.java:652)
> t 
> org.apache.batik.bridge.SVGTextElementBridge.buildGraphicsNode(SVGTextElementBridge.java:286)
>       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.build(GVTBuilder.java:82)
>         ...
> {code}
> However, the 'build' method should throw a 'BridgeException', as documented, 
> and as also thrown for various other problems, like DOM errors.
> 2) If the original SVG image is OK, but I programmatically set the 
> 'stroke-width' to '-3', I get the following printed to stderr:
> {code}
> java.lang.IllegalArgumentException: negative width
>       at java.desktop/java.awt.BasicStroke.<init>(BasicStroke.java:194)
>       at 
> org.apache.batik.bridge.PaintServer.convertStroke(PaintServer.java:649)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.setBaseTextPaintInfo(SVGTextElementBridge.java:1911)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.getTextPaintInfo(SVGTextElementBridge.java:1893)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.addChildPaintAttributes(SVGTextElementBridge.java:1458)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.addPaintAttributes(SVGTextElementBridge.java:1441)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(SVGTextElementBridge.java:652)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge.handleCSSEngineEvent(SVGTextElementBridge.java:730)
>       at 
> org.apache.batik.bridge.SVGTextElementBridge$AbstractTextChildBridgeUpdateHandler.handleCSSEngineEvent(SVGTextElementBridge.java:2175)
>       at 
> org.apache.batik.bridge.BridgeContext$CSSPropertiesChangedListener.propertiesChanged(BridgeContext.java:1741)
>       at 
> org.apache.batik.css.engine.CSSEngine.firePropertiesChangedEvent(CSSEngine.java:1830)
>       at 
> org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2095)
>       at 
> org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2031)
>       at 
> org.apache.batik.css.engine.CSSEngine.inlineStyleAttributeUpdated(CSSEngine.java:1898)
>       at 
> org.apache.batik.css.engine.CSSEngine.handleAttrModified(CSSEngine.java:2319)
>       at 
> org.apache.batik.css.engine.CSSEngine$CSSNavigableDocumentHandler.attrModified(CSSEngine.java:2481)
>       at 
> org.apache.batik.anim.dom.SVGOMDocument$DOMAttrModifiedListenerWrapper.handleEvent(SVGOMDocument.java:679)
>       at 
> org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:320)
>       at 
> org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:362)
>       at 
> org.apache.batik.dom.events.EventSupport.dispatchEvent(EventSupport.java:273)
>       at 
> org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:1012)
>       at 
> org.apache.batik.dom.AbstractElement.fireDOMAttrModifiedEvent(AbstractElement.java:661)
>       at 
> org.apache.batik.anim.dom.AbstractElement.fireDOMAttrModifiedEvent(AbstractElement.java:118)
>       at org.apache.batik.dom.AbstractAttr.setNodeValue(AbstractAttr.java:156)
>       at org.apache.batik.dom.AbstractAttr.setValue(AbstractAttr.java:199)
>       at 
> org.apache.batik.dom.AbstractElement.setAttributeNS(AbstractElement.java:265)
>       at 
> org.apache.batik.anim.dom.SVGStylableElement$StyleDeclaration.propertyChanged(SVGStylableElement.java:729)
>       at 
> org.apache.batik.css.dom.CSSOMStyleDeclaration.setProperty(CSSOMStyleDeclaration.java:157)
>         ...
> {code}
> This is due to the following code from 'EventSupport', which calls 
> 'printStackTrace' on the exception, rather than reporting it via the user 
> agent: 
> https://github.com/apache/xmlgraphics-batik/blob/dc3f248a141e035805b5d39585d40aabb6bfd010/batik-dom/src/main/java/org/apache/batik/dom/events/EventSupport.java#L336



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

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

Reply via email to