summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorK-Adam <kecskes.adam@outlook.com>2021-07-28 11:49:08 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-29 01:24:03 +0200
commit15cdb702c2fa13e7612a24338029295237b17af6 (patch)
tree490560621530fa4ec819e566adbf33e880fbe2d8 /Userland/Libraries/LibWeb
parente426e15101657ecf96567b84e7173278a95a90c7 (diff)
downloadserenity-15cdb702c2fa13e7612a24338029295237b17af6.zip
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; } } ```
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp
index 92d7d636a4..0163fd733b 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp
@@ -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;
+ }
}
}
}