LibWeb: Use code unit offsets in Document::find_matching_text()

We were passing in byte offsets instead of UTF-16 code unit offsets,
which could lead to crashes if the offsets found exceeded the number of
code units in text fragments on the page.

Fixes #4908.

Co-authored-by: Tim Ledbetter <tim.ledbetter@ladybird.org>
This commit is contained in:
Jelle Raaijmakers 2025-06-10 16:14:05 +02:00 committed by Jelle Raaijmakers
commit b42c2c5e8f
Notes: github-actions[bot] 2025-06-13 13:10:45 +00:00
5 changed files with 24 additions and 15 deletions

View file

@ -24,7 +24,7 @@ public:
size_t start_offset { 0 };
};
struct TextBlock {
String text;
AK::Utf16ConversionResult text;
Vector<TextPosition> positions;
};
Vector<TextBlock> const& text_blocks();