Olivier Vitry created BATIK-1266:
------------------------------------
Summary: ImageTranscoder prints Stacktrace instead of throwing
exception on invalid CSS in SVG
Key: BATIK-1266
URL: https://issues.apache.org/jira/browse/BATIK-1266
Project: Batik
Issue Type: Bug
Components: CSS
Affects Versions: 1.11
Reporter: Olivier Vitry
While trying to transcode a SVG containing invalid CSS, a org.w3c.DOMException
is directly printed to stdout instead of being thrown. This makes usage of the
Transcoder API limited in this case since logging the error and formatting it
for end users is not possible.
The code that seems responsible for the problem is in CSSEngine inside method
getCascadedStyleMap :
{code:java}
DOMException de = new DOMException((short)12,s);
if (this.userAgent == null){
throw de;
}
this.userAgent.displayError(de);
{code}
Repro steps :
* Create a SVG containing deliberate invalid CSS
* Convert to PNG using PNGTranscoder
Following is a code snippet for bug reproduction :
{code:java}
public void testKo() throws TranscoderException, IOException {
//svg with path containing stroke-miterlimit="14.00;"
File svgFile = new File("D:\\temp\\batik\\svgko.svg");
OutputStream outputStream = new
FileOutputStream("D:\\temp\\batik\\raster.png");
PNGTranscoder transcoder = new PNGTranscoder();
TranscoderInput transcoderInput = new
TranscoderInput(svgFile.toURI().toString());
TranscoderOutput transcoderOutput = new TranscoderOutput(outputStream);
try {
transcoder.transcode(transcoderInput, transcoderOutput);
} catch (DOMException e){
//never printed
System.out.println("exception found");
} finally {
outputStream.flush();
outputStream.close();
}
}
{code}
The following is printed on execution :
{noformat}
org.w3c.dom.DOMException: file:/D:/temp/batik/svgko.svg:
The attribute "stroke-miterlimit" represents an invalid CSS value ("14.00;").
Original message:
End of file expected.
at
org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(CSSEngine.java:775)
at
org.apache.batik.css.engine.CSSEngine.getComputedStyle(CSSEngine.java:867)
{noformat}
--
This message was sent by Atlassian Jira
(v8.3.2#803003)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]