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

svgLib: handle arc commands with bool flags not separated by space/comma #2094

Merged
merged 1 commit into from
Nov 11, 2020

Conversation

anthrotype
Copy link
Member

Some SVG authoring tool write arc commands without any space or comma around the boolean 'large-arc' and 'sweep' flags, leading our svg path parser to choke.
E.g. A1.2 1.2 0 0122 6.2 is currently tokenized as ["A", "1.2", "1.2", "0", "0122", "6.2"], whereas it should instead be tokenized as ["A", "1.2", "1.2", "0", "0", "1", "22", "6.2"]

This PR makes the path parser smarter by special-casing arc command so that we only consume one character ('0' or '1') for these special boolean flags.

Some SVG authoring tool write arc commands without any space or comma around the boolean 'large-arc' and 'sweep' flags, leading our svg path parser to choke.
This makes the path parser smarter by special-casing arc command parsing so that it only consumes one character ('0' or '1') for these special boolean flags.
yield token
continue

if arc_cmd:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional, if you are going to branch for arcs you could just write a regex specifically for arc (e.g. flag should be 0/1, has optional whitespace, etc)

@anthrotype anthrotype merged commit e7494bb into master Nov 11, 2020
@anthrotype anthrotype deleted the svg-arc-flags-no-spaces branch November 11, 2020 19:20
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 this pull request may close these issues.

None yet

2 participants