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

incorrect syntax for svg_path in SVG2 draft #946

Open
verdy-p opened this issue Jun 21, 2024 · 0 comments
Open

incorrect syntax for svg_path in SVG2 draft #946

verdy-p opened this issue Jun 21, 2024 · 0 comments

Comments

@verdy-p
Copy link

verdy-p commented Jun 21, 2024

The specification says (https://www.w3.org/TR/SVG/paths.html#PathDataBNF):

svg_path::= wsp* moveto? (moveto drawto_command*)?

but this is still not correct:

  • the initial optional moveto? is unnecessary, it is implied by the rest.
  • this very incorrectly limits the number of moveto to just 1 or 2, only at start of the path (including moveto into drawto_command seems incorrect semantically).
  • there's missing whitespaces between moveto and drawto_command.
  • there are missing optional whitespaces at end.

This should just be:

svg_path::= wsp* (moveto wsp* drawto_command*)* wsp*

Note also that various SVG renderers and web browsers (and all the "SVG path validators" I found on the Internet) also accept silenttly any trailing comma at end of coordinates or coordinate_pairs, just like if they were whitespace, and in fact all commas are treated by them exactly like whitespace everywhere (including in W3C SVG validator).

The only place where these trailing/extra commas may cause problem and that I found was in the Wikimedia SVG renderer used on their wikis (such as Wikimedia Commons): this is not visible in their SVG file upload preview (apparently the Wikimedia SVG-to-PNG thumbnail renderer is not used in that form as the file in preview is actually not saved and accessible to its renderer, just present in the input form data), the SVG is just shown embedded into the HTML page, and rendered by the web browser and may look correct, until after it is saved, and partly rendered, the rendering stops at the first extra comma).

So I wonder if these comma separators should not just be treated everywhere like whitespaces (as done in most existing SVG or validators and in HTML5 browsers like Google Chrome, Chromium, MSEdge). I have not tested how these "extra" commas behave in Firefox, Safari, or legacy renderers.

@verdy-p verdy-p changed the title incorrect syntax for svg_path in SVG3 draft incorrect syntax for svg_path in SVG2 draft Jun 21, 2024
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

No branches or pull requests

1 participant