diff options
author | miere43 <x.miere@gmail.com> | 2021-05-08 23:19:32 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-09 11:24:04 +0200 |
commit | 1e0e8b27c06ff6776d8b56a6cc4c545c007f8d1e (patch) | |
tree | e1592e1e0ac2697d288d5cfe4f4f04fc45ce801d /Userland/Libraries/LibWeb | |
parent | 10a594e6fe7063a309b28a7245f5a2c0a21c10cd (diff) | |
download | serenity-1e0e8b27c06ff6776d8b56a6cc4c545c007f8d1e.zip |
LibWeb: Allow white space inside pseudo-class arguments
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp index 63970e07ae..b30cd6023e 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp @@ -369,9 +369,14 @@ public: return original_index != index; } - bool is_valid_selector_char(char ch) const + static bool is_valid_selector_char(char ch) { - return isalnum(ch) || ch == '-' || ch == '_' || ch == '(' || ch == ')' || ch == '@'; + return isalnum(ch) || ch == '-' || ch == '+' || ch == '_' || ch == '(' || ch == ')' || ch == '@'; + } + + static bool is_valid_selector_args_char(char ch) + { + return is_valid_selector_char(ch) || ch == ' ' || ch == '\t'; } bool is_combinator(char ch) const @@ -513,8 +518,19 @@ public: return {}; buffer.append(')'); } else { - while (is_valid_selector_char(peek())) - buffer.append(consume_one()); + int nesting_level = 0; + while (true) { + const auto ch = peek(); + if (ch == '(') + ++nesting_level; + else if (ch == ')' && nesting_level > 0) + --nesting_level; + + if (nesting_level > 0 ? is_valid_selector_args_char(ch) : is_valid_selector_char(ch)) + buffer.append(consume_one()); + else + break; + }; } auto pseudo_name = String::copy(buffer); |