LibWeb: Allow white space inside pseudo-class arguments
This commit is contained in:
parent
10a594e6fe
commit
1e0e8b27c0
Notes:
sideshowbarker
2024-07-18 18:27:56 +09:00
Author: https://github.com/miere43 🔰 Commit: https://github.com/SerenityOS/serenity/commit/1e0e8b27c06 Pull-request: https://github.com/SerenityOS/serenity/pull/6968 Reviewed-by: https://github.com/awesomekling
1 changed files with 20 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue