1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 03:05:07 +00:00

LibWeb: Handle comment blocks when skipping unknown @-rules

This css definition was parsed incorrectly before:

```css
@media screen {
    /* Unclosed bracket in comment { */
    body {
        background: red;
    }
}
```
This commit is contained in:
K-Adam 2021-07-28 11:49:08 +02:00 committed by Andreas Kling
parent e426e15101
commit 15cdb702c2

View file

@ -1428,18 +1428,29 @@ public:
} }
// FIXME: We ignore other @-rules completely for now. // FIXME: We ignore other @-rules completely for now.
while (peek() != 0 && peek() != '{')
consume_one();
int level = 0; int level = 0;
for (;;) { bool in_comment = false;
while (peek() != 0) {
auto ch = consume_one(); auto ch = consume_one();
if (ch == '{') {
if (!in_comment) {
if (ch == '/' && peek() == '*') {
consume_one();
in_comment = true;
} else if (ch == '{') {
++level; ++level;
} else if (ch == '}') { } else if (ch == '}') {
--level; --level;
if (level == 0) if (level == 0)
break; break;
} }
} else {
if (ch == '*' && peek() == '/') {
consume_one();
in_comment = false;
}
}
} }
} }