mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
AK+LibJS+LibWeb: Recognize that our UTF-16 string is actually WTF-16
For the web, we allow a wobbly UTF-16 encoding (i.e. lonely surrogates are permitted). Only in a few exceptional cases do we strictly require valid UTF-16. As such, our `validate(AllowLonelySurrogates::Yes)` calls will always succeed. It's a wasted effort to ever make such a check. This patch eliminates such invocations. The validation methods will now only check for strict UTF-16, and are only invoked when needed.
This commit is contained in:
Notes:
github-actions[bot]
2025-08-13 13:57:41 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/8472e469f4e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5762
@@ -807,7 +807,7 @@ void FormAssociatedTextControlElement::handle_insert(Utf16String const& data)
|
||||
if (auto max_length = text_node->max_length(); max_length.has_value()) {
|
||||
auto remaining_length = *max_length - text_node->length_in_utf16_code_units();
|
||||
if (remaining_length < data.length_in_code_units())
|
||||
data_for_insertion = Utf16String::from_utf16_without_validation(data.substring_view(0, remaining_length));
|
||||
data_for_insertion = Utf16String::from_utf16(data.substring_view(0, remaining_length));
|
||||
}
|
||||
|
||||
auto selection_start = this->selection_start();
|
||||
|
||||
Reference in New Issue
Block a user