LibWeb/CSS: Don't remove whitespace early when parsing descriptor values
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

This commit is contained in:
Tim Ledbetter 2025-07-03 06:21:50 +01:00 committed by Sam Atkins
commit af60e36122
Notes: github-actions[bot] 2025-07-03 07:23:40 +00:00
2 changed files with 16 additions and 15 deletions

View file

@ -30,11 +30,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
if (unprocessed_tokens.peek_token().is(Token::Type::Semicolon))
break;
// FIXME: Stop removing whitespace here. It's just for compatibility with the property-parsing code.
auto const& token = unprocessed_tokens.consume_a_token();
if (token.is(Token::Type::Whitespace))
continue;
component_values.append(token);
}
@ -64,6 +60,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
case DescriptorMetadata::ValueType::CropOrCross: {
// crop || cross
auto first = parse_keyword_value(tokens);
tokens.discard_whitespace();
auto second = parse_keyword_value(tokens);
if (!first)
@ -135,6 +132,8 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
if (first_length->is_length() && first_length->as_length().length().raw_value() < 0)
return nullptr;
tokens.discard_whitespace();
if (auto second_length = parse_length_value(tokens)) {
if (second_length->is_length() && second_length->as_length().length().raw_value() < 0)
return nullptr;
@ -160,6 +159,8 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
return nullptr;
}
tokens.discard_whitespace();
if (auto second_keyword = parse_keyword_value(tokens)) {
if (orientation.is_null() && first_is_one_of(second_keyword->to_keyword(), Keyword::Landscape, Keyword::Portrait)) {
orientation = second_keyword.release_nonnull();

View file

@ -2,18 +2,18 @@ Harness status: OK
Found 95 tests
92 Pass
3 Fail
Pass "u/**/+/**/a/**/?" => "U+A0-AF"
89 Pass
6 Fail
Fail "u/**/+/**/a/**/?" => "U+A0-AF"
Pass "u+abc" => "U+ABC"
Pass "U+abc" => "U+ABC"
Pass "u+ABC" => "U+ABC"
Pass "U+ABC" => "U+ABC"
Pass "u+AbC" => "U+ABC"
Pass "u+efg" is invalid
Fail "u+ abc" is invalid
Fail "u +abc" is invalid
Fail "u + abc" is invalid
Pass "u+ abc" is invalid
Pass "u +abc" is invalid
Pass "u + abc" is invalid
Pass "U + a b c" is invalid
Pass "u+a" => "U+A"
Pass "u+aa" => "U+AA"
@ -34,7 +34,7 @@ Pass "u+a??????" is invalid
Pass "u+a?a" is invalid
Pass "u+aaaaaa" is invalid
Pass "u+a?????" is invalid
Pass "u/**/+0a/**/?" => "U+A0-AF"
Fail "u/**/+0a/**/?" => "U+A0-AF"
Pass "u+0a" => "U+A"
Pass "U+0a0" => "U+A0"
Pass "u+0aaaaa" => "U+AAAAA"
@ -51,7 +51,7 @@ Pass "u+0a?????" is invalid
Pass "u+00a????" is invalid
Pass "u+22222a" is invalid
Pass "u+1e9a" => "U+1E9A"
Pass "u/**/+0/**/?" => "U+0-F"
Fail "u/**/+0/**/?" => "U+0-F"
Pass "u/**/0" is invalid
Pass "u+0" => "U+0"
Pass "u+00" => "U+0"
@ -70,7 +70,7 @@ Pass "u+1e3" => "U+1E3"
Pass "u+1e-20" => "U+1E-20"
Pass "u+222222" is invalid
Pass "u+2?????" is invalid
Pass "u/**/+0/**/-0a" => "U+0-A"
Fail "u/**/+0/**/-0a" => "U+0-A"
Pass "u+0-0a" => "U+0-A"
Pass "u+000000-0aaaaa" => "U+0-AAAAA"
Pass "u+0000000-0a" is invalid
@ -80,7 +80,7 @@ Pass "u+0+0a" is invalid
Pass "u+0?-0a" is invalid
Pass "u+0-0a?" is invalid
Pass "u+222222-22222a" is invalid
Pass "u/**/+0/**/-1" => "U+0-1"
Fail "u/**/+0/**/-1" => "U+0-1"
Pass "u+0-1" => "U+0-1"
Pass "u-0-1" is invalid
Pass "u-0+1" is invalid
@ -91,7 +91,7 @@ Pass "u+0-0000001" is invalid
Pass "u+0-10ffff" => "U+0-10FFFF"
Pass "u+0-110000" is invalid
Pass "u+0-222222" is invalid
Pass "u/**/+/**/?" => "U+0-F"
Fail "u/**/+/**/?" => "U+0-F"
Pass "u+?" => "U+0-F"
Pass "u+?????" => "u+0-FFFFF"
Pass "u+???????" is invalid