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

SVG id attribute not validated. #1977

Closed
MewPurPur opened this issue Feb 13, 2024 · 1 comment
Closed

SVG id attribute not validated. #1977

MewPurPur opened this issue Feb 13, 2024 · 1 comment
Assignees
Labels
bug Something isn't working svg SVG features

Comments

@MewPurPur
Copy link
Collaborator

MewPurPur commented Feb 13, 2024

https://svgwg.org/svg2-draft/struct.html#Core.attrib

image

So the id attribute should only work with strings that are a non-zero length sequence of ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]

The id attribute is meant to go by NmToken rules. But instead, it works for everything, even empty strings. Example:

<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><linearGradient id="" x2="1"><stop stop-color="#fac"/></linearGradient><rect width="16" height="16" fill="url(#)"/></svg>

@MewPurPur MewPurPur added bug Something isn't working svg SVG features labels Feb 13, 2024
JSUYA added a commit to JSUYA/thorvg that referenced this issue Feb 14, 2024
empty id is invalid. Therefore, set it to null and make it is not used.

issue: thorvg#1977
hermet pushed a commit that referenced this issue Feb 15, 2024
empty id is invalid. Therefore, set it to null and make it is not used.

issue: #1977
@MewPurPur
Copy link
Collaborator Author

Okay, let's see.

User agents should process "id" values in SVG files irrespective of XML validity.

So we only need to abide by the following:

The "id" attribute must be unique within the node tree, must not be an empty string, and must not contain any whitespace characters.

So we're good with id's for now.

hermet pushed a commit that referenced this issue Feb 23, 2024
empty id is invalid. Therefore, set it to null and make it is not used.

issue: #1977
hermet pushed a commit that referenced this issue Apr 5, 2024
empty id is invalid. Therefore, set it to null and make it is not used.

issue: #1977
hermet pushed a commit that referenced this issue Apr 6, 2024
empty id is invalid. Therefore, set it to null and make it is not used.

issue: #1977
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working svg SVG features
Projects
Status: Done 0.13
Development

No branches or pull requests

2 participants