css4j / echosvg

SVG implementation in the Java™ Language, fork of Apache Batik, supporting level 4 selectors and colors.
Apache License 2.0
40 stars 2 forks source link

The SVG 1.2 dom implementation fails to load the user agent stylesheet #111

Closed zbynek closed 3 months ago

zbynek commented 3 months ago

The default DOM implementation uses InputSource backed by reader, the 1.2 implemeentation a source backed by URL (the url is jar:file:/.../echosvg-anim-1.1.1.jar!/io/sf/carte/echosvg/anim/dom/resources/UserAgentStyleSheet.css) Content type of such URL may be 'content/unknown' which results in an exception at https://github.com/css4j/css4j/blob/bbcd001c04f0157be91dc6885b4bdfbf8e84074c/src/main/java/io/sf/carte/doc/style/css/parser/CSSParser.java#L238

(I've seen this error on a Windows machine and could not reproduce on a Linux one, assuming this has something to do with content type handling on OS/JVM level...)

It seems redundant to check content type of a file that's bundled in a jar. Maybe SVG 1.2 implementation could share more code from the superclass that circumvents this check.

carlosame commented 3 months ago

Thanks for the bug report. The issue is now fixed, and I added a Mermaid test to the CI that checks the EchoSVG jar files distributed from the Maven repository. So any similar issue should be detected immediately now.

I invite you to try EchoSVG 1.2 which has the fix.