Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e20361406fa4eff234e8bd59de694af6d82dfe72
https://github.com/WebKit/WebKit/commit/e20361406fa4eff234e8bd59de694af6d82dfe72
Author: Ahmad Saleem <[email protected]>
Date: 2026-07-02 (Thu, 02 Jul 2026)
Changed paths:
M Source/WebCore/editing/TextIterator.cpp
M Tools/TestWebKitAPI/CMakeLists.txt
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WebCore/TextIterator.cpp
Log Message:
-----------
containsPlainText() re-scans the document head and misses matches past the
first search-buffer fill
https://bugs.webkit.org/show_bug.cgi?id=318304
rdar://181100516
Reviewed by Darin Adler.
SearchBuffer::append() consumes characters from the front of the given
text up to the remaining buffer capacity and returns the count consumed,
so the caller must feed it the unconsumed tail each iteration. The loop
in containsPlainText() advanced remainingText by that count but passed
the full `document` to append() every time, re-appending the same head.
Documents that fit in the buffer were consumed in one pass, hiding the
bug. Larger documents re-scanned the head forever and never examined
text past the first buffer fill, returning false for matches present
later in the string. Pass remainingText to append() instead.
Test: Tools/TestWebKitAPI/Tests/WebCore/TextIterator.cpp
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::containsPlainText):
* Tools/TestWebKitAPI/CMakeLists.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebCore/TextIterator.cpp: Added.
(TestWebKitAPI::TEST(TextIteratorTest,
ContainsPlainTextMatchWithinFirstBuffer)):
(TestWebKitAPI::TEST(TextIteratorTest, ContainsPlainTextNoMatch)):
(TestWebKitAPI::TEST(TextIteratorTest,
ContainsPlainTextMatchPastFirstBufferFill)):
Canonical link: https://commits.webkit.org/316442@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications