Skip to content

SVG paths: parsing NaN and Infinity#552

Open
nicoburns wants to merge 2 commits into
linebender:mainfrom
nicoburns:svg-parse-nan-infinity
Open

SVG paths: parsing NaN and Infinity#552
nicoburns wants to merge 2 commits into
linebender:mainfrom
nicoburns:svg-parse-nan-infinity

Conversation

@nicoburns
Copy link
Copy Markdown

@nicoburns nicoburns commented Mar 6, 2026

Allows paths like M0,0 L0,0 L90,0 LNaN,NaN to be parsed. This is useful for deserializing paths encoded in AnyRender serialized scenes. Otherwise deserializing panics.

(one might argue that we ought to strip NaN's and Infinity's from scene's, but we may also want to specifically test for them, so I think it is best to at least have the capability to preserve them)

@nicoburns nicoburns changed the title SVG: parsing NaN and Infinity SVG path parser: implement parsing NaN and Infinity Mar 6, 2026
@nicoburns nicoburns changed the title SVG path parser: implement parsing NaN and Infinity SVG paths: parsing NaN and Infinity Mar 6, 2026
@jneem
Copy link
Copy Markdown
Member

jneem commented Mar 17, 2026

I went to see if the svg spec had anything to say about this, but AFAICT the grammar doesn't even mention decimal points? Although the paragraph after the grammar clearly assumes that they're in there 😕

@raphlinus
Copy link
Copy Markdown
Contributor

This doesn't feel right to me, I would consider non-finite values to be invalid. I think ideally deserialization should fail but not panic.

I confirm @jneem's observation, the SVG 2 "spec" is obviously defective. However, SVG 1.1 has a clear grammar in which these would be rejected.

@nicoburns
Copy link
Copy Markdown
Author

I've vendored a copy of kurbo's path parsing code into anyrender_serialize. So I guess if this is a "no" then we should just close it.

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.

3 participants