[webkit-changes] [WebKit/WebKit] a2b978: [CoreIPC] The pasteboard may perform image convers...

Aditya Keerthi noreply at github.com
Wed Dec 20 08:16:42 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a2b978878b87687dffe753c836b7181e7a0f9276
      https://github.com/WebKit/WebKit/commit/a2b978878b87687dffe753c836b7181e7a0f9276
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    M Source/WebCore/PAL/pal/spi/cocoa/FoundationSPI.h
    M Source/WebCore/PAL/pal/spi/mac/NSPasteboardSPI.h
    M Source/WebCore/platform/Pasteboard.cpp
    M Source/WebCore/platform/Pasteboard.h
    M Source/WebCore/platform/PlatformPasteboard.h
    M Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
    M Source/WebCore/platform/mac/PasteboardMac.mm
    M Source/WebCore/platform/mac/PlatformPasteboardMac.mm
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm
    M Source/WebKit/UIProcess/WebPasteboardProxy.h
    M Source/WebKit/UIProcess/WebPasteboardProxy.messages.in
    M Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
    M Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm
    M Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm

  Log Message:
  -----------
  [CoreIPC] The pasteboard may perform image conversion in UIProcess
https://bugs.webkit.org/show_bug.cgi?id=263622
rdar://98996437

Reviewed by Wenson Hsieh.

When reading data from the pasteboard, image conversion may be performed
when using `NSTIFFPboardType` as the requested type. This is a system feature,
where a PNG can be written to the pasteboard, and a TIFF can be read out.
However, this is undesirable from a WebKit perspective, as it allows for
arbitrary image conversion across the process boundary.

Fix by ensuring that the UI process always returns the original data, and
perform the image conversion in the Web process.

* Source/WebCore/PAL/pal/spi/cocoa/FoundationSPI.h:
* Source/WebCore/PAL/pal/spi/mac/NSPasteboardSPI.h:

Declare an internal `NSPasteboard` method to obtain the unconverted data.

* Source/WebCore/platform/Pasteboard.cpp:
* Source/WebCore/platform/Pasteboard.h:
(WebCore::Pasteboard::bufferConvertedToPasteboardType):
* Source/WebCore/platform/PlatformPasteboard.h:
* Source/WebCore/platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::bufferForType const):
* Source/WebCore/platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::bufferConvertedToPasteboardType):

Perform the conversion to TIFF using CoreGraphics in the Web process.

* Source/WebCore/platform/mac/PlatformPasteboardMac.mm:
(WebCore::PlatformPasteboard::bufferForType const):

When requesting `NSTIFFPboardType`, and an image source is available on the
pasteboard, return the original data and the original type, rather than
performing image conversion.

(WebCore::PlatformPasteboard::readBuffer const):
* Source/WebKit/Scripts/webkit/messages.py:
(headers_for_type):
* Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
(WebKit::WebPasteboardProxy::getPasteboardBufferForType):
* Source/WebKit/UIProcess/WebPasteboardProxy.h:
* Source/WebKit/UIProcess/WebPasteboardProxy.messages.in:
* Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::bufferForType):
* Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::bufferForType):
* Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm:
(-[LocalPasteboard _dataWithoutConversionForType:securityScoped:]):

Override `_dataWithoutConversionForType:securityScoped:` since the custom
subclass used for testing does not account for pasteboard generation and
simply overrides `dataForType:`.

Without this implementation, the change would result in a call to the base
class and crash in `CFPasteboardGetGenerationCount`.

Originally-landed-as: 267815.441 at safari-7617-branch (d4645ae84721). rdar://119596032
Canonical link: https://commits.webkit.org/272348@main




More information about the webkit-changes mailing list