Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read crashes with SVG containing empty <polygon> tag #260

Closed
tatarize opened this issue Apr 19, 2021 · 3 comments · Fixed by #261
Closed

read crashes with SVG containing empty <polygon> tag #260

tatarize opened this issue Apr 19, 2021 · 3 comments · Fixed by #261

Comments

@tatarize
Copy link
Contributor

meerk40t/svgelements#105

            if isinstance(elem, svgelements.Polygon):
                path.append(svgelements.Close(elem.points[-1], elem.points[0]))

A polygon of <polygon points=""> in svg creates a polygon of zero points and as such that line causes an index error. I checked the SVG spec for the error handling of 0 point polygons and it says "The initial value, (none), indicates that the polygon element is valid, but does not render." Which means svgelements is in error when it produces a degenerate polygon in that case.

@tatarize
Copy link
Contributor Author

This will be corrected in svgelements 1.4.11. The parsing somewhat represents the render tree and as such degenerate shapes which are not to be rendered will not be returned as parsed. So Rect with widths of 0 will also be omitted going forward.

@abey79 abey79 changed the title Guard against minor svgelements bug. read crashes with SVG containing empty <polygon> tag Apr 19, 2021
@abey79
Copy link
Owner

abey79 commented Apr 19, 2021

For reference in case someone else encounters this bug, this is the error shown when this happens:

 File "c:\users\ohmar\virtualenvironments\vpype_venv\lib\site-packages\vpype\io.py", line 189, in _extract_paths
    path = [svgelements.Move(elem.points[0]), elem]
IndexError: list index out of range

@tatarize
Copy link
Contributor Author

tatarize commented May 3, 2021

1.4.11 was published and should omit degenerate shapes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants