Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f22a4386b7f213365c5cf30ef5597160e39b0b1f
https://github.com/WebKit/WebKit/commit/f22a4386b7f213365c5cf30ef5597160e39b0b1f
Author: Cole Carley <[email protected]>
Date: 2026-07-20 (Mon, 20 Jul 2026)
Changed paths:
A
LayoutTests/editing/async-clipboard/sanitize-when-reading-and-writing-svg-expected.txt
A
LayoutTests/editing/async-clipboard/sanitize-when-reading-and-writing-svg.html
M
LayoutTests/imported/w3c/web-platform-tests/clipboard-apis/clipboard-item.https-expected.txt
M Source/WebCore/Modules/async-clipboard/Clipboard.cpp
M Source/WebCore/Modules/async-clipboard/ClipboardImageReader.cpp
M Source/WebCore/Modules/async-clipboard/ClipboardImageReader.h
M Source/WebCore/Modules/async-clipboard/ClipboardItem.cpp
M Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp
M Source/WebCore/Modules/async-clipboard/ios/ClipboardImageReaderIOS.mm
M Source/WebCore/Modules/async-clipboard/mac/ClipboardImageReaderMac.mm
M Source/WebCore/dom/Element.cpp
M Source/WebCore/dom/Element.h
M Source/WebCore/editing/markup.cpp
M Source/WebCore/editing/markup.h
M Source/WebCore/platform/cocoa/PasteboardCocoa.mm
M Source/WebCore/platform/glib/PasteboardGLib.cpp
M Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
M Source/WebCore/platform/mac/PlatformPasteboardMac.mm
M Source/WebKit/UIProcess/gtk/WebPasteboardProxyGtk.cpp
M Source/WebKit/UIProcess/wpe/WebPasteboardProxyWPE.cpp
M Tools/WebKitTestRunner/PlatformMac.cmake
Log Message:
-----------
sf-saas.apple.com: Support copy/paste of SVG data
https://bugs.webkit.org/show_bug.cgi?id=318829
rdar://137553836
Reviewed by Wenson Hsieh.
The clipboard (navigator.clipboard) did not support image/svg+xml.
SVG could not simply be allowed through like other image types because
it can carry scripts, event handlers, javascript: URLs, and external
references.
This patch adds image/svg+xml as a supported clipboard type and sanitizes
it on both the write and read paths, modeled on the sanitization baseline
in the Sanitizer API (https://wicg.github.io/sanitizer-api/).
I also removed content hidden with display: none. To do this, I added a
new callback to sanitizeMarkup that get's run post-layout, so we have
access to the computed style of each element.
*
LayoutTests/editing/async-clipboard/sanitize-when-reading-and-writing-svg-expected.txt:
Added.
*
LayoutTests/editing/async-clipboard/sanitize-when-reading-and-writing-svg.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/clipboard-apis/clipboard-item.https-expected.txt:
* Source/WebCore/Modules/async-clipboard/Clipboard.cpp:
(WebCore::Clipboard::getType):
* Source/WebCore/Modules/async-clipboard/ClipboardImageReader.cpp:
(WebCore::ClipboardImageReader::readBuffer):
(WebCore::ClipboardImageReader::readSVG):
* Source/WebCore/Modules/async-clipboard/ClipboardImageReader.h:
* Source/WebCore/Modules/async-clipboard/ClipboardItem.cpp:
(WebCore::ClipboardItem::supports):
* Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp:
(WebCore::ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::sanitizeDataIfNeeded):
* Source/WebCore/Modules/async-clipboard/ios/ClipboardImageReaderIOS.mm:
(WebCore::ClipboardImageReader::readBuffer):
* Source/WebCore/Modules/async-clipboard/mac/ClipboardImageReaderMac.mm:
(WebCore::ClipboardImageReader::readBuffer):
* Source/WebCore/editing/markup.cpp:
(WebCore::sanitizeMarkup):
(WebCore::sanitizeSVG):
(WebCore::sanitizedMarkupForFragmentInDocument):
* Source/WebCore/editing/markup.h:
* Source/WebCore/platform/cocoa/PasteboardCocoa.mm:
(WebCore::cocoaTypeToImageType):
(WebCore::imageTypeToMIMEType):
(WebCore::imageTypeToFakeFilename):
* Source/WebCore/platform/glib/PasteboardGLib.cpp:
(WebCore::Pasteboard::read):
* Source/WebCore/platform/ios/PlatformPasteboardIOS.mm:
(WebCore::safeTypeForDOMToReadAndWriteForPlatformType):
(WebCore::PlatformPasteboard::platformPasteboardTypeForSafeTypeForDOMToReadAndWrite):
* Source/WebCore/platform/mac/PlatformPasteboardMac.mm:
(WebCore::PlatformPasteboard::platformPasteboardTypeForSafeTypeForDOMToReadAndWrite):
(WebCore::webSafeMIMETypeForModernPasteboardType):
* Source/WebKit/UIProcess/gtk/WebPasteboardProxyGtk.cpp:
(WebKit::WebPasteboardProxy::writeCustomData):
(WebKit::pasteboardItemInfoFromFormats):
* Source/WebKit/UIProcess/wpe/WebPasteboardProxyWPE.cpp:
(WebKit::WebPasteboardProxy::writeCustomData):
(WebKit::pasteboardItemInfoFromFormats):
* Tools/WebKitTestRunner/PlatformMac.cmake:
Canonical link: https://commits.webkit.org/317528@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications