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

@ -814,7 +814,7 @@ public:
// Does document represent an embedded svg img
[[nodiscard]] bool is_decoded_svg() const;
Vector<GC::Root<DOM::Range>> find_matching_text(String const&, CaseSensitivity);
Vector<GC::Root<Range>> find_matching_text(String const&, CaseSensitivity);
void parse_html_from_a_string(StringView);
static GC::Ref<Document> parse_html_unsafe(JS::VM&, StringView);