GNOME Bugzilla – Bug 620923
MASTER: Path data garbled / coordinates mangled
Last modified: 2015-04-07 17:20:32 UTC
Created attachment 162998 [details] [review] Path handling patch [Bug description adapted from bug 620565] Overview: In path data, a fractional constant such as ".5", or a constant with an exponent such as "-9E-7" followed by a negative number, are sometimes misinterpreted and replaced by another seemingly arbitrary value. This value can be much larger, resulting in very distorted paths. The SVG specs allow omitting the leading zero[1]. As path data is an essential core component of SVG, I permitted myself, like the reporter of bug 620565, to set the bug severity to major. Steps to Reproduce: 1) View any of the following attachments with rsvg-view or EOG. For actual and expected results for each file, see XML comments. [End of steps] Opera, Firefox, Google Chrome, Batik and Inkscape render the file as expected. Build Date & Platform: package librsvg2-2, version 2.26.0-1 on Ubuntu Karmic Additional Builds and Platforms: The same problems can be experienced on Wikipedia.
Created attachment 162999 [details] Crossing rectangle attachment from bug 620565 [Thomas W.] [1] http://www.w3.org/TR/SVG/paths.html#PathDataBNF
Created attachment 163000 [details] Overlapping lines attachment from bug 620565 [Thomas W.]
Created attachment 163001 [details] Trash can icon from the Humanity theme (Ubuntu 10.04) optimised by Scour
http://upload.wikimedia.org/wikipedia/commons/3/3c/Obcine_Slovenija_2006_Crensovci.svg This file is more than 1000 KB, and as such cannot be uploaded to this bug. However, it was the test case provided in the Ubuntu bug for this general class of path data problems: https://bugs.launchpad.net/ubuntu/+source/librsvg/+bug/370061
Thank you for opening a new bug. I'd expect some test codes instead of test file. I mean unit tests.
90% of the unit tests are failing on my system right now, due to fonts being different, and the $Revision: 1.1 $ tags from the W3C SVG conformance test suite (.png) being $Revision: 1.7 $ in the .svg files. And all the unit tests currently in librsvg *are* .svg files and their reference .png images. I could make a test .svg file with coordinates affected by this bug and give the expected render for it, I guess. (Or perhaps: How am I to do this?)
So, some unit tests are not just failing because of fonts. They're failing because of the fixed coordinate handling from this patch. The unit tests "succeeded" before, but only because of rendering assumed good with outstanding bugs still in librsvg, or the relative age of the spec implemented. I see references to the "SVG draft" in the file rsvg-path.c, for instance. As an example of a test that now renders more closely to what is expected of the SVG spec, but is now a failing unit test:
Created attachment 163124 [details] tests/bugs/563933.svg
Created attachment 163125 [details] tests/bugs/563933-ref.png [What the unit test expected .svg to render as]
Created attachment 163126 [details] tests/bugs/563933-out.png [What the unit test rendered as after this patch] Note how the expected render has half-gray "leaves" and the render after this patch doesn't. You can see an example of this by opening -ref.png in GIMP and looking at pixel coordinates (166, 309). It looks as if all the unit tests would have to be reviewed as well as my future unit test, if approved.
I am sorry, I did not explain what I expect exactly. "Unit tests" I meant is unit tests for rsvg_parse_number().
Created attachment 163222 [details] Unit test: tests/bugs/620923.svg This is the best I could do, since I don't really know my way around the C language: An SVG file with only paths and a rectangle, but all the paths taken together have all the possible ways to specify integers and fractional numbers in the SVG spec, and any number parsed incorrectly makes either a slanted line or a blotch of red.
Created attachment 163223 [details] Unit test reference render: tests/bugs/620923-ref.png This is what the previous file is supposed to render as.
Created attachment 163224 [details] Unit test PRE-PATCH render Lots of red and slanted lines in librsvg before this patch.
ok. I will write the test codes. Thanks a lot!
Ping! Bug status?
This bug also occurs in version 2.32.1-0ubuntu1. Is there any update on this problem? Thank you.
*** Bug 620565 has been marked as a duplicate of this bug. ***
*** Bug 620821 has been marked as a duplicate of this bug. ***
Bug is still reproducible in 2.40.5. It there anything that blocks fixing this bug?
ChPe, any chance you can take a look into this? Any SVG I optimized using svgo [0] hit this bug. My librsvg was rather old, but I trust people saying this is still reproducible. If you won't have time, I can try myself, but since you seem to have been looking after this library... Thanks. [0] http://github.com/svg/svgo
See also: http://commons.wikimedia.org/wiki/Librsvg_bugs
Committed the patch after fixing up. commit 5ba4343bccc7e1765f38f87490b3d6a3a500fde1 Author: Behdad Esfahbod <behdad@behdad.org> Date: Sun Nov 9 17:24:09 2014 -0800 Fix path data number parsing Previously highly-optimized path data was being garbled during loading. A patch has been available for over four years. Fix it. This is pretty much the same patch as one submitted by Louis Simard, which I verified was correct except for two cases where it was using "&=" when "|=" was intended. https://bugzilla.gnome.org/show_bug.cgi?id=620923
*** Bug 747428 has been marked as a duplicate of this bug. ***