[jira] [Created] (BATIK-1266) ImageTranscoder prints Stacktrace instead of throwing exception on invalid CSS in SVG
"Olivier Vitry (Jira)" <[email protected]> Mon, 9 Sep 2019 14:34:00 +0000 (UTC)
| Newsgroups | gmane.text.xml.batik.devel |
|---|---|
| Message-ID | <[email protected]> |
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.DOMExcept=
ion 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 for=
matting it for end users is not possible.
The code that seems responsible for the problem is in CSSEngine inside meth=
od getCascadedStyleMap :
{code:java}
DOMException de =3D new DOMException((short)12,s);
if (this.userAgent =3D=3D null){
throw de;
}
this.userAgent.displayError(de);
{code}
=C2=A0
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=3D"14.00;"
File svgFile =3D new File("D:\\temp\\batik\\svgko.svg");
OutputStream outputStream =3D new FileOutputStream("D:\\temp\\batik\\ra=
ster.png");
PNGTranscoder transcoder =3D new PNGTranscoder();
TranscoderInput transcoderInput =3D new TranscoderInput(svgFile.toURI()=
.toString());
TranscoderOutput transcoderOutput =3D 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.getCascadedStyleMa=
p(CSSEngine.java:775)
at org.apache.batik.css.engine.CSSEngine.getComputedStyle(C=
SSEngine.java:867)
{noformat}
--
This message was sent by Atlassian Jira
(v8.3.2#803003)