After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 620923 - MASTER: Path data garbled / coordinates mangled
MASTER: Path data garbled / coordinates mangled
Status: RESOLVED FIXED
Product: librsvg
Classification: Core
Component: general
2.26.x
Other All
: Normal major
: ---
Assigned To: librsvg maintainers
librsvg maintainers
: 620565 620821 747428 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-06-08 03:42 UTC by Louis Simard
Modified: 2015-04-07 17:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Path handling patch (7.71 KB, patch)
2010-06-08 03:42 UTC, Louis Simard
none Details | Review
Crossing rectangle attachment from bug 620565 [Thomas W.] (730 bytes, image/svg+xml)
2010-06-08 03:45 UTC, Louis Simard
  Details
Overlapping lines attachment from bug 620565 [Thomas W.] (408 bytes, image/svg+xml)
2010-06-08 03:46 UTC, Louis Simard
  Details
Trash can icon from the Humanity theme (Ubuntu 10.04) optimised by Scour (23.70 KB, image/svg+xml)
2010-06-08 03:47 UTC, Louis Simard
  Details
tests/bugs/563933.svg (32.03 KB, image/svg+xml)
2010-06-08 23:42 UTC, Louis Simard
  Details
tests/bugs/563933-ref.png [What the unit test expected .svg to render as] (37.41 KB, image/png)
2010-06-08 23:43 UTC, Louis Simard
  Details
tests/bugs/563933-out.png [What the unit test rendered as after this patch] (38.12 KB, image/png)
2010-06-08 23:47 UTC, Louis Simard
  Details
Unit test: tests/bugs/620923.svg (2.42 KB, image/svg+xml)
2010-06-09 18:48 UTC, Louis Simard
  Details
Unit test reference render: tests/bugs/620923-ref.png (1.10 KB, image/png)
2010-06-09 18:49 UTC, Louis Simard
  Details
Unit test PRE-PATCH render (5.91 KB, image/png)
2010-06-09 19:01 UTC, Louis Simard
  Details

Description Louis Simard 2010-06-08 03:42:38 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.
Comment 1 Louis Simard 2010-06-08 03:45:00 UTC
Created attachment 162999 [details]
Crossing rectangle attachment from bug 620565 [Thomas W.]

[1] http://www.w3.org/TR/SVG/paths.html#PathDataBNF
Comment 2 Louis Simard 2010-06-08 03:46:12 UTC
Created attachment 163000 [details]
Overlapping lines attachment from bug 620565 [Thomas W.]
Comment 3 Louis Simard 2010-06-08 03:47:11 UTC
Created attachment 163001 [details]
Trash can icon from the Humanity theme (Ubuntu 10.04) optimised by Scour
Comment 4 Louis Simard 2010-06-08 03:52:19 UTC
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
Comment 5 Hiroyuki Ikezoe 2010-06-08 10:46:07 UTC
Thank you for opening a new bug.

I'd expect some test codes instead of test file. I mean unit tests.
Comment 6 Louis Simard 2010-06-08 22:39:52 UTC
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?)
Comment 7 Louis Simard 2010-06-08 23:40:58 UTC
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:
Comment 8 Louis Simard 2010-06-08 23:42:32 UTC
Created attachment 163124 [details]
tests/bugs/563933.svg
Comment 9 Louis Simard 2010-06-08 23:43:29 UTC
Created attachment 163125 [details]
tests/bugs/563933-ref.png [What the unit test expected .svg to render as]
Comment 10 Louis Simard 2010-06-08 23:47:16 UTC
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.
Comment 11 Hiroyuki Ikezoe 2010-06-09 10:59:41 UTC
I am sorry, I did not explain what I expect exactly. "Unit tests" I meant is unit tests for rsvg_parse_number().
Comment 12 Louis Simard 2010-06-09 18:48:26 UTC
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.
Comment 13 Louis Simard 2010-06-09 18:49:20 UTC
Created attachment 163223 [details]
Unit test reference render: tests/bugs/620923-ref.png

This is what the previous file is supposed to render as.
Comment 14 Louis Simard 2010-06-09 19:01:39 UTC
Created attachment 163224 [details]
Unit test PRE-PATCH render

Lots of red and slanted lines in librsvg before this patch.
Comment 15 Hiroyuki Ikezoe 2010-06-10 11:35:47 UTC
ok. I will write the test codes. Thanks a lot!
Comment 16 Louis Simard 2010-08-01 00:30:43 UTC
Ping! Bug status?
Comment 17 Teej 2010-12-27 16:59:40 UTC
This bug also occurs in version 2.32.1-0ubuntu1. Is there any update on this problem? Thank you.
Comment 18 Christian Persch 2011-11-09 19:42:19 UTC
*** Bug 620565 has been marked as a duplicate of this bug. ***
Comment 19 Christian Persch 2011-11-09 19:42:33 UTC
*** Bug 620821 has been marked as a duplicate of this bug. ***
Comment 20 Evgeny Kolesnikov 2014-10-24 06:16:02 UTC
Bug is still reproducible in 2.40.5. It there anything that blocks fixing this bug?
Comment 21 Behdad Esfahbod 2014-10-28 22:22:29 UTC
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
Comment 22 Behdad Esfahbod 2014-10-28 22:44:14 UTC
See also: http://commons.wikimedia.org/wiki/Librsvg_bugs
Comment 23 Behdad Esfahbod 2014-11-10 01:26:16 UTC
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
Comment 24 Felix Riemann 2015-04-07 17:20:32 UTC
*** Bug 747428 has been marked as a duplicate of this bug. ***