Opened 7 years ago

Closed 5 years ago

#15561 closed defect (fixed)

[patch][cla] Reg Exp for the path is incorrect causing render to not work as expected

Reported by: j105rob Owned by: Eric Durocher
Priority: high Milestone: 1.10
Component: DojoX GFX Version: 1.7.1
Keywords: Cc:
Blocked By: Blocking:


pathSvgRegExp variable defined as /([A-Za-z])|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g

does not correctly parse the path; should a segment of a path be defined in scientific notation (e.g. -6e-9) the result of the regex does not pass the correct information into the shape object and causes the render to render the image incorrectly;

We modified the regex to: /(\d+(\.\d+)?[Ee]-\d+)|(-\d+(\.\d+)?[Ee]-\d+)|([A-Za-z])|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g

which allowed the expected data to be passed to the renderer and rendered the image as expected.

I am not submitting a patch file because we have other changes we need to submit, but this is a bug which can be fixed in the short term.

Thanks, j105Rob.

Change History (6)

comment:1 Changed 6 years ago by dylan

Per Thomas L. Shinnick on the mailing list:

As described above. Still broken in 1.8.3. Here's what I was going to submit before finding this report:

Dojox/gfx::createPath fails on numbers with exponents

Working with path strings as output to SVG files by popular external program "Inkscape". These path strings often contain a full range of number value formats, including numbers with exponents.

The number format for path data in SVG is documented

The format is described as

      number ::= integer ([Ee] integer)?
                 | [+-]? [0-9]* "." [0-9]+ ([Ee] integer)?

To split up incoming path strings into actions and arguments


uses a regex published as


This regex does not recognize number exponents and so the parsed path string has scattered 'E' and/or 'e' "actions" leftover. This causes paths to not be displayed, presumably because of the invalid actions.

Fix is to recognize numbers that include exponents.

--- _base.js.original   2012-07-30 20:46:04.000000000 -0500
+++ _base.js    2013-02-21 19:40:15.899727000 -0600
@@ -902,7 +902,7 @@
                //              a constant regular expression used to split a SVG/VML path into primitive components
                // tags:
                //              private
-               pathSvgRegExp: /([A-Za-z])|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g,
+               pathSvgRegExp: /([A-DF-Za-df-z])|([-+]?\d*[.]?\d+(?:[eE][-+]?\d+)?)/g,

                equalSources: function(a, b){
                        // summary:

Note that this regex reflects the number formats in SVG specs. There is one format that is not permitted there -- "9." -- an integer followed by a decimal point *not* followed by other digits. A more permissive regex might be more bulletproof.

I have not yet looked at modifications to tests to prove the failing.
Edit: since the bug database had errors preventing my comment a couple days ago, I looked at the tests. These modifications show the problem and the fix:

C:\Toms\Study\bliss\JS\dojo1\static\dojox\gfx\tests>diff test_setPath.html.original test_setPath.html
<               .createPath("M100 100 200 100 200 200C200 250 150 250 100 200S50 100 100 100z")
>               .createPath("M100 100 200 100 200 200C200 250 150 250 1E2 200S50 1E2 1E2 100z")
<               .createPath("m100 100 100 0 0 100q0 50-75-25t-25-75z")
>               .createPath("m100 1E2 1E2 0 0 100q0 50-75-25t-25-75z")
<               .createPath("M100 100 200 100 200 200Q200 250 125 175T100 100z")
>               .createPath("M100 1E2 200 1E2 200 200Q200 250 125 175T100 100z")
<               .createPath("m100 100h100v100q0 50-75-25t-25-75z")
>               .createPath("m100 100h100v1E2q0 50-75-25t-25-75z")

comment:2 Changed 6 years ago by dylan

Milestone: tbd1.9
Priority: undecidedhigh
Summary: Reg Exp for the path is incorrect causing render to not work as expected[patch][cla] Reg Exp for the path is incorrect causing render to not work as expected

Verified that both j105b and Thomas have CLAs on file.

We should fix this for 1.9.

comment:3 Changed 6 years ago by bill

Milestone: 1.91.10

Bumping this ticket since we are past the deadline for the 1.9RC. The fix can be put into 1.9.1 too, if desired.

comment:4 Changed 5 years ago by Eugene Lazutkin

Looks trivial enough, and follows the standard. Should be committed.

comment:5 Changed 5 years ago by dylan

Owner: changed from Eugene Lazutkin to Eric Durocher
Status: newassigned

comment:6 Changed 5 years ago by Eric Durocher

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.