mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +00:00
AK+Everywhere: Allow lonely UTF-16 surrogates by default
By definition, the web allows lonely surrogates by default. Let's have our string APIs reflect this, so we don't have to pass an allow option all over the place.
This commit is contained in:
parent
86b1c78c1a
commit
9fc3e72db2
Notes:
github-actions[bot]
2025-07-03 13:53:17 +00:00
Author: https://github.com/trflynn89
Commit: 9fc3e72db2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5228
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/shannonbooth
14 changed files with 74 additions and 77 deletions
|
@ -1393,7 +1393,7 @@ ThrowCompletionOr<String> get_substitution(VM& vm, Utf16View const& matched, Utf
|
|||
|
||||
// 2. Let groupName be the substring of templateRemainder from 2 to gtPos.
|
||||
auto group_name_view = template_remainder.substring_view(2, *greater_than_position - 2);
|
||||
auto group_name = MUST(group_name_view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
auto group_name = MUST(group_name_view.to_utf8());
|
||||
|
||||
// 3. Assert: namedCaptures is an Object.
|
||||
VERIFY(named_captures.is_object());
|
||||
|
@ -1435,7 +1435,7 @@ ThrowCompletionOr<String> get_substitution(VM& vm, Utf16View const& matched, Utf
|
|||
}
|
||||
|
||||
// 6. Return result.
|
||||
return MUST(Utf16View { result }.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
return MUST(Utf16View { result }.to_utf8());
|
||||
}
|
||||
|
||||
void DisposeCapability::visit_edges(GC::Cell::Visitor& visitor) const
|
||||
|
|
|
@ -99,7 +99,7 @@ Optional<size_t> string_index_of(Utf16View const& string, Utf16View const& searc
|
|||
static bool is_string_well_formed_unicode(Utf16View string)
|
||||
{
|
||||
// OPTIMIZATION: simdutf can do this much faster.
|
||||
return string.validate();
|
||||
return string.validate(AllowLonelySurrogates::No);
|
||||
}
|
||||
|
||||
// 11.1.4 CodePointAt ( string, position ), https://tc39.es/ecma262/#sec-codepointat
|
||||
|
|
|
@ -125,12 +125,12 @@ Utf16View Utf16String::substring_view(size_t code_unit_offset) const
|
|||
|
||||
String Utf16String::to_utf8() const
|
||||
{
|
||||
return MUST(view().to_utf8(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
return MUST(view().to_utf8());
|
||||
}
|
||||
|
||||
ByteString Utf16String::to_byte_string() const
|
||||
{
|
||||
return MUST(view().to_byte_string(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
return MUST(view().to_byte_string());
|
||||
}
|
||||
|
||||
u16 Utf16String::code_unit_at(size_t index) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue