mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 10:09:14 +00:00
LibWeb: Allow splitting surrogate pairs in CharacterData.replaceData()
We're expected to handle this situation gracefully, and certainly not by falling apart like we were. Found by Domato.
This commit is contained in:
parent
416c478876
commit
33207174a9
Notes:
github-actions[bot]
2024-07-20 04:41:59 +00:00
Author: https://github.com/awesomekling 🔰
Commit: 33207174a9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/721
3 changed files with 23 additions and 2 deletions
|
@ -87,9 +87,9 @@ WebIDL::ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t coun
|
|||
// 6. Let delete offset be offset + data’s length.
|
||||
// 7. Starting from delete offset code units, remove count code units from node’s data.
|
||||
StringBuilder builder;
|
||||
builder.append(MUST(utf16_view.substring_view(0, offset).to_utf8()));
|
||||
builder.append(MUST(utf16_view.substring_view(0, offset).to_utf8(Utf16View::AllowInvalidCodeUnits::Yes)));
|
||||
builder.append(data);
|
||||
builder.append(MUST(utf16_view.substring_view(offset + count).to_utf8()));
|
||||
builder.append(MUST(utf16_view.substring_view(offset + count).to_utf8(Utf16View::AllowInvalidCodeUnits::Yes)));
|
||||
m_data = MUST(builder.to_string());
|
||||
|
||||
// 8. For each live range whose start node is node and start offset is greater than offset but less than or equal to offset plus count, set its start offset to offset.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue