[webkit-changes] [WebKit/WebKit] 73bbfd: Image copied from Notes and pasted in compose on g...

Wenson Hsieh noreply at github.com
Mon Oct 28 10:29:10 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 73bbfdc992ca78fa0e48a2571336519226ddcd26
      https://github.com/WebKit/WebKit/commit/73bbfdc992ca78fa0e48a2571336519226ddcd26
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2024-10-28 (Mon, 28 Oct 2024)

  Changed paths:
    M Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteRTFD.mm

  Log Message:
  -----------
  Image copied from Notes and pasted in compose on gmail.com does not get attached
https://bugs.webkit.org/show_bug.cgi?id=282159
rdar://138111842

Reviewed by Richard Robinson and Ryosuke Niwa.

When composing a new message in Gmail, right clicking an image in Notes and pasting into Gmail
causes an image to be inserted into the editable container, without triggering Gmail's logic to
actually upload the image data as a MIME attachment. As a result, the image appears in the compose
draft, but is lost upon sending. This happens because Gmail's logic to perform this file upload only
happens when consuming markup data, if the parsed markup doesn't contain any other tags except for
`HTML`, `HEAD`, `META`, `BODY` and a single `IMG` element.

When copying from the Notes app, a length-2 attributed string is written to the pasteboard; the
first character is the object replacement character (`0xFFFC`) that has a text attachment attribute,
and the second character is a newline character.

Pasting from Chrome inserts a markup string that contains only a single `IMG` element, but pasting
from Safari inserts a document fragment that consists of a `P` element that contains the `IMG`,
alongside a `BR` as the next sibling of the `P`. As such, we fail the aforementioned check in Gmail
and don't trigger their attachment upload logic.

To fix this, we add a heuristic to detect this case where the attributed string contains only a
single text attachment (with an optional newline character after the object replacement character),
and simplify the serialized document fragment such that it contains only a single `IMG` or `PICTURE`
element, to more closely match Chrome's behavior.

* Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::simplifyFragmentForSingleTextAttachment):
(WebCore::createFragment):

See above for more details.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteRTFD.mm:
(TEST(PasteRTFD, ImageElementUsesBlobURLInHTML)):

Augment an existing API test to exercise this change.

Canonical link: https://commits.webkit.org/285770@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