mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
LibWeb: Correct escape handling in CSS Tokenizer
Calling is_valid_escape_sequence() with no arguments hides what it is operating on, so I have removed that, so that you must explicitly tell it what you are testing. The call from consume_a_token() was using the wrong tokens, so it returned false incorrectly. This was resulting in corrupted output when faced with this code from Acid2. (Abbreviated) ```css .parser { error: \}; } .parser { } ```
This commit is contained in:
parent
e381ca258f
commit
c249fbd17c
2 changed files with 3 additions and 9 deletions
|
@ -504,7 +504,7 @@ Token Tokenizer::consume_a_url_token()
|
|||
}
|
||||
|
||||
if (is_reverse_solidus(input)) {
|
||||
if (is_valid_escape_sequence()) {
|
||||
if (is_valid_escape_sequence(peek_twin())) {
|
||||
token.m_value.append_code_point(consume_escaped_code_point());
|
||||
} else {
|
||||
log_parse_error();
|
||||
|
@ -534,7 +534,7 @@ void Tokenizer::consume_the_remnants_of_a_bad_url()
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_valid_escape_sequence()) {
|
||||
if (is_valid_escape_sequence(peek_twin())) {
|
||||
[[maybe_unused]] auto cp = consume_escaped_code_point();
|
||||
}
|
||||
|
||||
|
@ -601,11 +601,6 @@ bool Tokenizer::starts_with_a_number(U32Triplet values)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Tokenizer::is_valid_escape_sequence()
|
||||
{
|
||||
return is_valid_escape_sequence(peek_twin());
|
||||
}
|
||||
|
||||
bool Tokenizer::is_valid_escape_sequence(U32Twin values)
|
||||
{
|
||||
if (!is_reverse_solidus(values.first)) {
|
||||
|
@ -864,7 +859,7 @@ Token Tokenizer::consume_a_token()
|
|||
|
||||
if (is_reverse_solidus(input)) {
|
||||
dbgln_if(CSS_TOKENIZER_TRACE, "is reverse solidus");
|
||||
if (is_valid_escape_sequence()) {
|
||||
if (is_valid_escape_sequence({ input, peek_code_point() })) {
|
||||
reconsume_current_input_code_point();
|
||||
return consume_an_ident_like_token();
|
||||
}
|
||||
|
|
|
@ -92,7 +92,6 @@ private:
|
|||
void consume_the_remnants_of_a_bad_url();
|
||||
void consume_comments();
|
||||
void reconsume_current_input_code_point();
|
||||
[[nodiscard]] bool is_valid_escape_sequence();
|
||||
[[nodiscard]] static bool is_valid_escape_sequence(U32Twin);
|
||||
[[nodiscard]] bool would_start_an_identifier();
|
||||
[[nodiscard]] bool would_start_an_identifier(U32Triplet);
|
||||
|
|
Loading…
Add table
Reference in a new issue