Page MenuHome

Fix for T87654: SVG import parse error
ClosedPublic

Authored by Erik Abrahamsson (erik85) on Apr 20 2021, 2:27 PM.

Details

Summary

Fix for SVG data when there is no space between some arguments in the arc command.
See T87654 for example files.

See https://www.w3.org/TR/SVG2/paths.html#TheDProperty for arguments to the elliptical arc curve commands.

Diff Detail

Event Timeline

Erik Abrahamsson (erik85) requested review of this revision.Apr 20 2021, 2:27 PM
Erik Abrahamsson (erik85) created this revision.
Erik Abrahamsson (erik85) edited the summary of this revision. (Show Details)

Added fixes for DeprecationWarning related to regular expressions.

Sergey Sharybin (sergey) requested changes to this revision.Apr 21 2021, 12:17 PM

Thanks for the patch!
Here is some of the easy-to-address feedback before we can commit this.

io_curve_svg/import_svg.py
408

Call it current_command, avoid over-commenting.

421

Is more like arg_index as it is not a number of arguments, but a 1-based index.

423–435

The code needs an explanation about why the 'a' is so special, since the code below is not very trivial.

io_curve_svg/svg_util.py
86–88 ↗(On Diff #36326)

Please cover this with test in the svg_util_test.py

This revision now requires changes to proceed.Apr 21 2021, 12:17 PM
Erik Abrahamsson (erik85) marked 4 inline comments as done.

I was a bit quick to assume things. This should be enough to make it parse the arcs correctly.

Thanks for the clarification.
One more tiny suggestion and think code is fine!

io_curve_svg/import_svg.py
431

I'd say lets always advance the arg_index, so that if other command needs it can use it. It will also make the arg_index semantically more clear (it then will become "argument index of the current command" instead of "argument index of the current command if the command is 'a'").

Erik Abrahamsson (erik85) marked an inline comment as done.
Erik Abrahamsson (erik85) edited the summary of this revision. (Show Details)

Good point, updated now.

Seems good now!

I'll commit the fix to 2.93 now (seems you don't have commit access to addons yet).

This revision is now accepted and ready to land.Apr 22 2021, 12:49 PM