blackears / svgSalamander

158 stars 57 forks source link

Problem with special chars #47

Closed SimonIT closed 4 years ago

SimonIT commented 5 years ago

While using nidi3/graphviz-java with RandomStringUtils.random(10) from commons-lang, these exceptions occurred:

[Fatal Error] :476:17: Ungültiges XML-Zeichen (Unicode: 0x17) wurde im Kommentar gefunden.
Okt. 28, 2019 4:54:14 NACHM. com.kitfox.svg.SVGUniverse loadSVG
WARNUNG: Error processing svgSalamander://graph/
org.xml.sax.SAXParseException; lineNumber: 476; columnNumber: 17; Ungültiges XML-Zeichen (Unicode: 0x17) wurde im Kommentar gefunden.
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1243)
    at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635)
    at com.kitfox.svg.SVGUniverse.loadSVG(SVGUniverse.java:608)
    at com.kitfox.svg.SVGUniverse.loadSVG(SVGUniverse.java:545)
    at com.kitfox.svg.SVGUniverse.loadSVG(SVGUniverse.java:502)
    at guru.nidi.graphviz.engine.SalamanderRasterizer.createDiagram(SalamanderRasterizer.java:60)
    at guru.nidi.graphviz.engine.SalamanderRasterizer.doRasterize(SalamanderRasterizer.java:32)
    at guru.nidi.graphviz.engine.SvgRasterizer.rasterize(SvgRasterizer.java:35)
    at guru.nidi.graphviz.engine.Renderer.toImage(Renderer.java:117)
    at guru.nidi.graphviz.engine.EngineResult.map(EngineResult.java:58)
    at guru.nidi.graphviz.engine.Renderer.toImage(Renderer.java:109)
    at guru.nidi.graphviz.engine.Renderer.toImage(Renderer.java:105)
    at de.szut.simNil.binaryMaple.gui.TreeVisualizer.getGraphvizImage(TreeVisualizer.java:187)
    at de.szut.simNil.binaryMaple.gui.AbstractController.lambda$updateGraphvizImage$10(AbstractController.java:232)
    at java.base/java.lang.Thread.run(Thread.java:834)
[WARNING] 
java.lang.NullPointerException
    at guru.nidi.graphviz.engine.SalamanderRasterizer.createDiagram (SalamanderRasterizer.java:62)
    at guru.nidi.graphviz.engine.SalamanderRasterizer.doRasterize (SalamanderRasterizer.java:32)
    at guru.nidi.graphviz.engine.SvgRasterizer.rasterize (SvgRasterizer.java:35)
    at guru.nidi.graphviz.engine.Renderer.toImage (Renderer.java:117)
    at guru.nidi.graphviz.engine.EngineResult.map (EngineResult.java:58)
    at guru.nidi.graphviz.engine.Renderer.toImage (Renderer.java:109)
    at guru.nidi.graphviz.engine.Renderer.toImage (Renderer.java:105)
    at de.szut.simNil.binaryMaple.gui.TreeVisualizer.getGraphvizImage (TreeVisualizer.java:187)
    at de.szut.simNil.binaryMaple.gui.AbstractController.lambda$updateGraphvizImage$10 (AbstractController.java:232)
    at java.lang.Thread.run (Thread.java:834)

See here nidi3/graphviz-java#130

blackears commented 5 years ago

This might be a problem with the SAX parser and not something I can fix. Do you have a sample of the SVG you were loading that caused this issue?

SimonIT commented 5 years ago

Sadly no, I'm only using nidi3/graphviz-java and have actually no clue what it internally does. Maybe @nidi3 or @mx1up can give more details

nidi3 commented 5 years ago

Indeed, I believe it's a bad interaction between random and SAX parser. As far as I understand, random should not generate chars < ' ', but somtimes SAX parser interprets some of them as < ' ' which are invalid inside XML. I'll fix this in graphviz-java by replacing all chars < ' ' with ' '.

blackears commented 4 years ago

I thought it looks like an invalid XML syntax issue. Thanks for addressing this.