weisJ/jsvg

ArrayIndexOutOfBoundsException when loading SVG

Closed this issue · 2 comments

When loading the attached SVG file I get the following stacktrace:

Jan 30, 2022 10:32:56 AM com.github.weisj.jsvg.parser.SVGLoader load WARNING: Could not load SVG java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1 at com.github.weisj.jsvg/com.github.weisj.jsvg.parser.AttributeNode.preprocessAttributes(AttributeNode.java:77) at com.github.weisj.jsvg/com.github.weisj.jsvg.parser.AttributeNode.<init>(AttributeNode.java:60) at com.github.weisj.jsvg/com.github.weisj.jsvg.parser.SVGLoader$SVGLoadHandler.startElement(SVGLoader.java:232) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:518) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2725) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:541) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224) at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635) at com.github.weisj.jsvg/com.github.weisj.jsvg.parser.SVGLoader.load(SVGLoader.java:136) at com.github.weisj.jsvg/com.github.weisj.jsvg.parser.SVGLoader.load(SVGLoader.java:124) at Encryption/crypttool.util.SVGIcon.<init>(SVGIcon.java:23) at Encryption/crypttool.gui.MainFrame.<clinit>(MainFrame.java:138) at Encryption/crypttool.Crypttool.main(Crypttool.java:41)

The file gets displayed perfectly fine in my browser. I tried to load another SVG file, which worked. Is there an issue with my svg file, or is it a bug in your library? Any potential workarounds?

The svg file causing the error:
password

Because I'm not sure how to attach the svg file, without it getting displayed as a preview, here is the code for the svg: https://pastebin.com/BEP1pEBk

weisJ commented

The issue seems to be the empty style tag <g style="">. Removing the style attribute should fix it.