Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fa10d866af3305a123a7ad62bc43e25d6438d8b8
      
https://github.com/WebKit/WebKit/commit/fa10d866af3305a123a7ad62bc43e25d6438d8b8
  Author: Charlie Wolfe <[email protected]>
  Date:   2026-06-19 (Fri, 19 Jun 2026)

  Changed paths:
    M Source/WebKit/Shared/TextExtractionToStringConversion.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.mm

  Log Message:
  -----------
  Underflow in truncateByWordCount when the word limit is zero
https://bugs.webkit.org/show_bug.cgi?id=317440

Reviewed by Wenson Hsieh.

A client can set maxWordsPerParagraph to 0, so when a paragraph has at least 
one word,
totalWords <= 0 is false and reaches the indexing with wordLimit == 0: 
`wordLimit - 1` wraps to
UINT64_MAX and indexes the Vector out of bounds. Treat a zero limit as "keep no 
words" and return
the ellipsis before the subtraction.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.mm
* Source/WebKit/Shared/TextExtractionToStringConversion.cpp:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.mm:
(TestWebKitAPI::TEST(TextExtractionTests, ZeroWordLimit)):

Canonical link: https://commits.webkit.org/315545@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to