mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Use substrings instead of pointers when parsing unicode ranges
Fixes a segfault when parsing a wildcard-only unicode range
This commit is contained in:
parent
ceedfb34d2
commit
a4b38dda56
Notes:
github-actions[bot]
2024-11-05 14:02:50 +00:00
Author: https://github.com/Gingeh Commit: https://github.com/LadybirdBrowser/ladybird/commit/a4b38dda561 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2172 Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 14 additions and 1 deletions
|
@ -0,0 +1 @@
|
|||
PASS (didn't crash)
|
11
Tests/LibWeb/Text/input/css/unicode-range-all-wildcard.html
Normal file
11
Tests/LibWeb/Text/input/css/unicode-range-all-wildcard.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<style>
|
||||
@font-face {
|
||||
unicode-range: U+??;
|
||||
}
|
||||
</style>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
println("PASS (didn't crash)");
|
||||
});
|
||||
</script>
|
|
@ -2217,6 +2217,7 @@ Optional<Gfx::UnicodeRange> Parser::parse_unicode_range(StringView text)
|
|||
|
||||
// 3. Consume as many hex digits from text as possible.
|
||||
// then consume as many U+003F QUESTION MARK (?) code points as possible.
|
||||
auto start_position = lexer.tell();
|
||||
auto hex_digits = lexer.consume_while(is_ascii_hex_digit);
|
||||
auto question_marks = lexer.consume_while([](auto it) { return it == '?'; });
|
||||
// If zero code points were consumed, or more than six code points were consumed,
|
||||
|
@ -2226,7 +2227,7 @@ Optional<Gfx::UnicodeRange> Parser::parse_unicode_range(StringView text)
|
|||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: <urange> start value had {} digits/?s, expected between 1 and 6.", consumed_code_points);
|
||||
return {};
|
||||
}
|
||||
StringView start_value_code_points { hex_digits.characters_without_null_termination(), consumed_code_points };
|
||||
StringView start_value_code_points = text.substring_view(start_position, consumed_code_points);
|
||||
|
||||
// If any U+003F QUESTION MARK (?) code points were consumed, then:
|
||||
if (question_marks.length() > 0) {
|
||||
|
|
Loading…
Reference in a new issue