Commit 84339e9
committed
Fix zero value parsing in SVG paths (resolves #228)
This commit fixes a bug where zero values in SVG path definitions were
incorrectly ignored when followed by whitespace and a decimal number.
For example, "0 0 0 .25" was being parsed as "0" "0" "0.25" instead of
the correct "0" "0" "0" "0.25".
The root cause was that the scanner's charactersToBeSkipped included all
whitespace, causing "0 .25" to be recognized as a single number "0.25".
Changes:
- Limited scanner.charactersToBeSkipped to only newlines (not all whitespace)
- Added explicit whitespace handling in the operand parsing loop
- This ensures zero values are correctly recognized as discrete operands
The fix ensures that the testPathValuesWithLeadingZeros test passes,
which verifies that shortcut SVG notations like "M 00.01 a 2 1 0 006 0"
parse correctly to match their expanded equivalents.1 parent 53088f7 commit 84339e9
1 file changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
550 | | - | |
| 550 | + | |
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
561 | 564 | | |
562 | 565 | | |
563 | 566 | | |
| |||
0 commit comments