[webkit-changes] [WebKit/WebKit] 2fd8f8: [Unified Text Replacement] Replacing text with non...

Richard Robinson noreply at github.com
Mon Mar 18 17:10:03 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2fd8f81aac4e867ffe107c0e1b3e34b1628c0953
      https://github.com/WebKit/WebKit/commit/2fd8f81aac4e867ffe107c0e1b3e34b1628c0953
  Author: Richard Robinson <richard_robinson2 at apple.com>
  Date:   2024-03-18 (Mon, 18 Mar 2024)

  Changed paths:
    M Source/WebCore/editing/cocoa/HTMLConverter.h
    M Source/WebCore/editing/cocoa/HTMLConverter.mm
    M Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm

  Log Message:
  -----------
  [Unified Text Replacement] Replacing text with non-trivial attributed string attributes can sometimes cause a crash
https://bugs.webkit.org/show_bug.cgi?id=271105
rdar://123712304

Reviewed by Aditya Keerthi.

Currently, the original selected range isn't guaranteed to fit within the context attributed string,
due to the slight differences between HTMLConverter and TextIterator. To fix, `editingAttributedString`
will now be used, which uses TextIterator itself. Also add an assertion to ensure this postcondition
is true.

The replaced, expanded selection range was also being formed incorrectly, impacting subsequent calls
of the function. A partial fix is done by using the context string instead of the replaced string,
since the range is relative to the former. Additionally, the `extendedBoundaryPoint` method is altered
to use a slightly different mechanism of expanding based on the number of characters, to completely
fix this issue.

Also add a precondition check to ensure the range passed in as the parameter is a valid range within
the context range.

* Source/WebCore/editing/cocoa/HTMLConverter.h:
* Source/WebCore/editing/cocoa/HTMLConverter.mm:
(WebCore::editingAttributedString):
* Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm:
(WebKit::extendedBoundaryPoint):
(WebKit::UnifiedTextReplacementController::willBeginTextReplacementSession):
(WebKit::UnifiedTextReplacementController::textReplacementSessionDidReceiveTextWithReplacementRange):

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



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


More information about the webkit-changes mailing list