[webkit-changes] [WebKit/WebKit] 3f8ad7: Add a codepath to adjust URLs and plain text befor...

Wenson Hsieh noreply at github.com
Tue Oct 18 18:37:58 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3f8ad758a672f42d1d38eb5789dee634da4c545e
      https://github.com/WebKit/WebKit/commit/3f8ad758a672f42d1d38eb5789dee634da4c545e
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2022-10-18 (Tue, 18 Oct 2022)

  Changed paths:
    M Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp
    M Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.h
    M Source/WebCore/dom/DataTransfer.cpp
    M Source/WebCore/dom/DataTransfer.h
    M Source/WebCore/dom/DataTransfer.idl
    M Source/WebCore/dom/DataTransferItemList.cpp
    M Source/WebCore/dom/DataTransferItemList.h
    M Source/WebCore/dom/DataTransferItemList.idl
    M Source/WebCore/editing/Editor.cpp
    M Source/WebCore/page/ChromeClient.h
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
    M Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.h

  Log Message:
  -----------
  Add a codepath to adjust URLs and plain text before writing to the system pasteboard
https://bugs.webkit.org/show_bug.cgi?id=246635
rdar://101212078

Reviewed by Aditya Keerthi.

Add codepaths to adjust URLs written via either programmatic clipboard APIs (i.e. DataTransfer,
async clipboard) or via the "Copy Link" context menu action. See below for more details.

* Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp:
(WebCore::ClipboardItemBindingsDataSource::collectDataForWriting):
(WebCore::ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::ClipboardItemTypeLoader):
(WebCore::ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::dataAsString const):
(WebCore::ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::sanitizeDataIfNeeded):
* Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.h:
(WebCore::ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::create):

For the programmatic clipboard APIs, we treat this URL sanitization in the same way as sanitized
markup, by writing the original unsanitized URL to pickled clipboard data, while writing the
sanitized URL to the pasteboard, but only in the case where the two differ.

* Source/WebCore/dom/DataTransfer.cpp:
(WebCore::DataTransfer::setData):
(WebCore::DataTransfer::setDataFromItemList):

Add a `Document&` argument to codepaths that can be used to programmatically write URL data to the
pasteboard.

* Source/WebCore/dom/DataTransfer.h:
* Source/WebCore/dom/DataTransfer.idl:

Add `[CallWith=CurrentDocument]` so that we can easily call into `Page` to sanitize URL data when
writing data to the pasteboard.

* Source/WebCore/dom/DataTransferItemList.cpp:
(WebCore::DataTransferItemList::add):
* Source/WebCore/dom/DataTransferItemList.h:
* Source/WebCore/dom/DataTransferItemList.idl:

Add `[CallWith=CurrentDocument]` here as well, so that we can easily call into `Page`.

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

Additionally sanitize URLs when copying a link via the context menu.

* Source/WebCore/page/ChromeClient.h:
(WebCore::ChromeClient::handlePDFServiceClick):
(WebCore::ChromeClient::sanitizeForCopyOrShare const):

Add a platform client hook to call "sanitize" the given URL.

* Source/WebCore/page/Page.cpp:
(WebCore::Page::sanitizeForCopyOrShare const):

Add a couple of helper methods on Page to sanitize either a given URL, or a given URL string.

* Source/WebCore/page/Page.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::sanitizeForCopyOrShare const):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::sanitizeForCopyOrShare const):

Add a new additions extension point.

* Source/WebKit/WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::sanitizeForCopyOrShare const):

Add a no-op stub implementation for non-Cocoa builds.

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




More information about the webkit-changes mailing list