Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1b25554251447179a862eb544b6323a473b9afc6
      
https://github.com/WebKit/WebKit/commit/1b25554251447179a862eb544b6323a473b9afc6
  Author: Aditya Keerthi <akeer...@apple.com>
  Date:   2024-07-29 (Mon, 29 Jul 2024)

  Changed paths:
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm

  Log Message:
  -----------
  REGRESSION (281060@main): [iOS] Crash when entering Japanese text into a text 
box
https://bugs.webkit.org/show_bug.cgi?id=277251
rdar://132702363

Reviewed by Wenson Hsieh.

281060@main introduced an unconditional call to
`-[NSAttributedString attributesAtIndex:effectiveRange:]` in the marked text
codepath, which is used for both IME and inline text predictions.

This is unsafe, as an empty string is inserted when accepting an IME 
composition.
Fix by eliding the call to `-[NSAttributedString 
attributesAtIndex:effectiveRange:]`
when the text is empty.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setAttributedMarkedText:selectedRange:]):
* Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
(TestWebKitAPI::TEST(KeyboardInputTests, NoCrashWithEmptyAttributedMarkedText)):

Reproducing the issue in a test requires the use of `NSMutableAttributedString`.
Specifically, the crash is in the run-length encoded array used to keep track
of attributes. The issue only reproduces when that array is modified. Simply
creating an empty attributed string is insufficient to reproduce the crash.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to