Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6103d1b95adad0e21a5b3cbd21059bd8488b8e76
https://github.com/WebKit/WebKit/commit/6103d1b95adad0e21a5b3cbd21059bd8488b8e76
Author: Ahmad Saleem <[email protected]>
Date: 2026-09-11 (Fri, 11 Sep 2026)
Changed paths:
M Source/WTF/wtf/text/WTFString.cpp
M Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.mm
Log Message:
-----------
makeStringByJoining() drops separators preceding the first non-empty string
https://bugs.webkit.org/show_bug.cgi?id=323919
rdar://187152412
Reviewed by Chris Dumez.
StringBuilder::isEmpty() was used as a stand-in for "is this the first element",
but it stays true until the first non-empty string is appended, so every
separator
before that point was dropped:
{ ""_s, "a"_s } with "\n" gave "a" not "\na"
{ ""_s, ""_s, "a"_s, "b"_s } with "\n" gave "a\nb" not "\n\na\nb"
Null strings behaved like empty ones; once a non-empty element was appended the
function was correct, so only an empty prefix was affected.
Interleave::writeUsing() in StringConcatenate.h is already the correct form of
this
loop, and interleave(container, between) is a ready-made overload, so express
makeStringByJoining() in terms of it instead of repairing the duplicate.
Behavior
is otherwise unchanged: the result still comes from StringBuilder::toString(),
so
an empty span still returns a non-null empty string.
Of the 41 callers, only truncateByWordCount() in
TextExtractionToStringConversion.cpp can pass an empty prefix - it splits with
splitAllowingEmptyEntries('\n') and never prunes. The others guard each append
with !isEmpty(), prune empty elements first (the m_lines join, which is why the
main text extraction output is unaffected), filter empties one layer down
(DataTransfer), or join values that cannot be empty.
textContent does not change, because every output format strips leading
whitespace. The visible symptom is filteredOutAnyText: its caller sets the flag
whenever truncated != text, and truncateByWordCount() has no early return for
text
already under the limit, so a paragraph opening with a blank line reported
filtered text when nothing had been filtered.
Tests: Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp
Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.mm
* Source/WTF/wtf/text/WTFString.cpp:
(WTF::makeStringByJoining):
* Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp:
(TestWebKitAPI::TEST(WTF, StringMakeStringByJoining)):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.mm:
(TestWebKitAPI::(TextExtractionTests,
WordLimitDoesNotReportFilteringLeadingBlankLines)):
Canonical link: https://commits.webkit.org/320911@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications