mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-17 16:42:54 +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:
parent
e426e15101
commit
15cdb702c2
Notes:
sideshowbarker
2024-07-18 07:56:35 +09:00
Author: https://github.com/K-Adam
Commit: 15cdb702c2
Pull-request: https://github.com/SerenityOS/serenity/pull/9066
1 changed files with 20 additions and 9 deletions
|
@ -1428,17 +1428,28 @@ public:
|
|||
}
|
||||
|
||||
// FIXME: We ignore other @-rules completely for now.
|
||||
while (peek() != 0 && peek() != '{')
|
||||
consume_one();
|
||||
int level = 0;
|
||||
for (;;) {
|
||||
bool in_comment = false;
|
||||
|
||||
while (peek() != 0) {
|
||||
auto ch = consume_one();
|
||||
if (ch == '{') {
|
||||
++level;
|
||||
} else if (ch == '}') {
|
||||
--level;
|
||||
if (level == 0)
|
||||
break;
|
||||
|
||||
if (!in_comment) {
|
||||
if (ch == '/' && peek() == '*') {
|
||||
consume_one();
|
||||
in_comment = true;
|
||||
} else if (ch == '{') {
|
||||
++level;
|
||||
} else if (ch == '}') {
|
||||
--level;
|
||||
if (level == 0)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (ch == '*' && peek() == '/') {
|
||||
consume_one();
|
||||
in_comment = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue