Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a90b28a5b1a806efdff51cf6d8420cf7b4852ba4
      
https://github.com/WebKit/WebKit/commit/a90b28a5b1a806efdff51cf6d8420cf7b4852ba4
  Author: Wenson Hsieh <[email protected]>
  Date:   2025-06-03 (Tue, 03 Jun 2025)

  Changed paths:
    A 
LayoutTests/editing/input/cocoa/untrusted-text-event-does-not-trigger-text-replacement-expected.txt
    A 
LayoutTests/editing/input/cocoa/untrusted-text-event-does-not-trigger-text-replacement.html
    M LayoutTests/editing/inserting/typing-space-to-trigger-smart-link.html
    M Source/WebCore/editing/Editor.cpp
    M Source/WebCore/editing/Editor.h
    M Source/WebCore/editing/TypingCommand.cpp

  Log Message:
  -----------
  [macOS] Safari AutoFill should not trigger text replacement
https://bugs.webkit.org/show_bug.cgi?id=293957
rdar://151984377

Reviewed by Aditya Keerthi and Abrar Rahman Protyasha.

Safari AutoFill works by dispatching `TextEvent`s to simulate user-triggered 
editing; however, this
means that it can also trigger text replacements on macOS — for instance, if 
the user has mapped the
string `name@` to `[email protected]` and AutoFill attempts to fill in login 
credentials using this
email address, we'll end up with `[email protected]` instead of just 
`[email protected]`, due to
fact that text replacement triggers immediately upon typing the `a` in 
`apple.com`.

To fix this, we prevent any untrusted `TextEvent` (i.e. created and dispatched 
via bindings) from
triggering text replacements when applying the edit command.

* 
LayoutTests/editing/input/cocoa/untrusted-text-event-does-not-trigger-text-replacement-expected.txt:
 Added.
* 
LayoutTests/editing/input/cocoa/untrusted-text-event-does-not-trigger-text-replacement.html:
 Added.

Add a layout test to exercise this fix; before the fix, we end up with 
`[email protected]`.

* LayoutTests/editing/inserting/typing-space-to-trigger-smart-link.html:

Adjust an existing test to work with this new behavior by using key events to 
exercise typing,
instead of creating and dispatching key/text events in JavaScript.

* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::markMisspellingsAfterTypingToWord):

Drive-by refactoring: also replace the `bool doReplacement` argument here with 
a strongly typed enum
class, to help clarify the intent of this parameter.

* Source/WebCore/editing/Editor.h:
* Source/WebCore/editing/TypingCommand.cpp:
(WebCore::TypingCommand::markMisspellingsAfterTyping):

Additionally check `!triggeringEventIsUntrusted()` when determining whether we 
should allow text
replacement (this is plumbed down from the result of `TextEvent::isTrusted()`).

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



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

Reply via email to