-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
fix(SVGParser): Don't crash on nested CSS at-rules #9707
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
I also verified this fix in the actual use case, and it did generate the black circle as expected. |
I added a condition so it looks for the |
i need to fix prettier or you can do it. |
Ran it. |
What do you recommend about this one? Should we ignore non-at-rule nesting as well? I don't really understand the purpose of the parser and whether it's better to crash or ignore. |
The parser has been written in 2010-2012 and supported ie7+ initially through a canvas polyfill. In general all that can be fixed will be fixed also depending on the popularity of the feature. |
Fixes #29326 because it includes fabricjs/fabric.js#9707.
Fixes go-gitea/gitea#29326 because it includes fabricjs/fabric.js#9707. (cherry picked from commit a9e5706696f7d593e281d33783877b7772e48e19)
Description
This will ignore all CSS rules that contain unbalanced brackets after splitting on
}
.circle { fill: black; }
splits tocircle { fill: black;
which has one{
, so it's okay.@media (prefers-color-scheme: dark) { circle { fill: white; } }
splits to@media (prefers-color-scheme: dark) { circle { fill: white;
which has two{
and starts with@
so is ignored.As mentioned in #9679 I think using a AST parser would be a much better option than this current crude parsing, for the future.
Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
Fixes: #9679