Title: [270310] branches/safari-610-branch
Revision
270310
Author
[email protected]
Date
2020-12-01 09:59:18 -0800 (Tue, 01 Dec 2020)

Log Message

Cherry-pick r270072. rdar://problem/71836681

    REGRESSION (r259151): The "Convert Text to Traditional Chinese" services menu action is broken
    https://bugs.webkit.org/show_bug.cgi?id=219190
    <rdar://problem/71438389>

    Reviewed by Tim Horton.

    Source/WebKit:

    Some system services, such as "Convert Text to (Traditional|Simplified) Chinese", use `-[NSServicesMenuRequestor
    readSelectionFromPasteboard:]` to insert the contents of the given pasteboard into the current selection. After
    the changes in r259151, this requires the UI process to explicitly grant access to the contents of the given
    pasteboard, on behalf of the web content process.

    Fix the bug by adding the missing call to `grantAccessToCurrentPasteboardData`. This is only called from API in
    the UI process, so it cannot be abused by a compromised web content process to grab the contents of
    `NSPasteboard`.

    Test: PasteHTML.ReadSelectionFromPasteboard

    * UIProcess/mac/WebPageProxyMac.mm:
    (WebKit::WebPageProxy::readSelectionFromPasteboard):

    Tools:

    Add an API test to exercise `-readSelectionFromPasteboard:`.

    * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm:
    (TEST):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270072 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610-branch/Source/WebKit/ChangeLog (270309 => 270310)


--- branches/safari-610-branch/Source/WebKit/ChangeLog	2020-12-01 17:59:02 UTC (rev 270309)
+++ branches/safari-610-branch/Source/WebKit/ChangeLog	2020-12-01 17:59:18 UTC (rev 270310)
@@ -1,3 +1,61 @@
+2020-12-01  Alan Coon  <[email protected]>
+
+        Cherry-pick r270072. rdar://problem/71836681
+
+    REGRESSION (r259151): The "Convert Text to Traditional Chinese" services menu action is broken
+    https://bugs.webkit.org/show_bug.cgi?id=219190
+    <rdar://problem/71438389>
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebKit:
+    
+    Some system services, such as "Convert Text to (Traditional|Simplified) Chinese", use `-[NSServicesMenuRequestor
+    readSelectionFromPasteboard:]` to insert the contents of the given pasteboard into the current selection. After
+    the changes in r259151, this requires the UI process to explicitly grant access to the contents of the given
+    pasteboard, on behalf of the web content process.
+    
+    Fix the bug by adding the missing call to `grantAccessToCurrentPasteboardData`. This is only called from API in
+    the UI process, so it cannot be abused by a compromised web content process to grab the contents of
+    `NSPasteboard`.
+    
+    Test: PasteHTML.ReadSelectionFromPasteboard
+    
+    * UIProcess/mac/WebPageProxyMac.mm:
+    (WebKit::WebPageProxy::readSelectionFromPasteboard):
+    
+    Tools:
+    
+    Add an API test to exercise `-readSelectionFromPasteboard:`.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm:
+    (TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270072 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-11-19  Wenson Hsieh  <[email protected]>
+
+            REGRESSION (r259151): The "Convert Text to Traditional Chinese" services menu action is broken
+            https://bugs.webkit.org/show_bug.cgi?id=219190
+            <rdar://problem/71438389>
+
+            Reviewed by Tim Horton.
+
+            Some system services, such as "Convert Text to (Traditional|Simplified) Chinese", use `-[NSServicesMenuRequestor
+            readSelectionFromPasteboard:]` to insert the contents of the given pasteboard into the current selection. After
+            the changes in r259151, this requires the UI process to explicitly grant access to the contents of the given
+            pasteboard, on behalf of the web content process.
+
+            Fix the bug by adding the missing call to `grantAccessToCurrentPasteboardData`. This is only called from API in
+            the UI process, so it cannot be abused by a compromised web content process to grab the contents of
+            `NSPasteboard`.
+
+            Test: PasteHTML.ReadSelectionFromPasteboard
+
+            * UIProcess/mac/WebPageProxyMac.mm:
+            (WebKit::WebPageProxy::readSelectionFromPasteboard):
+
 2020-11-16  Russell Epstein  <[email protected]>
 
         Cherry-pick r269651. rdar://problem/71442660

Modified: branches/safari-610-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (270309 => 270310)


--- branches/safari-610-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2020-12-01 17:59:02 UTC (rev 270309)
+++ branches/safari-610-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2020-12-01 17:59:18 UTC (rev 270310)
@@ -266,6 +266,8 @@
     if (!hasRunningProcess())
         return false;
 
+    grantAccessToCurrentPasteboardData(pasteboardName);
+
     bool result = false;
     const Seconds messageTimeout(20);
     sendSync(Messages::WebPage::ReadSelectionFromPasteboard(pasteboardName), Messages::WebPage::ReadSelectionFromPasteboard::Reply(result), messageTimeout);

Modified: branches/safari-610-branch/Tools/ChangeLog (270309 => 270310)


--- branches/safari-610-branch/Tools/ChangeLog	2020-12-01 17:59:02 UTC (rev 270309)
+++ branches/safari-610-branch/Tools/ChangeLog	2020-12-01 17:59:18 UTC (rev 270310)
@@ -1,3 +1,52 @@
+2020-12-01  Alan Coon  <[email protected]>
+
+        Cherry-pick r270072. rdar://problem/71836681
+
+    REGRESSION (r259151): The "Convert Text to Traditional Chinese" services menu action is broken
+    https://bugs.webkit.org/show_bug.cgi?id=219190
+    <rdar://problem/71438389>
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebKit:
+    
+    Some system services, such as "Convert Text to (Traditional|Simplified) Chinese", use `-[NSServicesMenuRequestor
+    readSelectionFromPasteboard:]` to insert the contents of the given pasteboard into the current selection. After
+    the changes in r259151, this requires the UI process to explicitly grant access to the contents of the given
+    pasteboard, on behalf of the web content process.
+    
+    Fix the bug by adding the missing call to `grantAccessToCurrentPasteboardData`. This is only called from API in
+    the UI process, so it cannot be abused by a compromised web content process to grab the contents of
+    `NSPasteboard`.
+    
+    Test: PasteHTML.ReadSelectionFromPasteboard
+    
+    * UIProcess/mac/WebPageProxyMac.mm:
+    (WebKit::WebPageProxy::readSelectionFromPasteboard):
+    
+    Tools:
+    
+    Add an API test to exercise `-readSelectionFromPasteboard:`.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm:
+    (TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270072 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-11-19  Wenson Hsieh  <[email protected]>
+
+            REGRESSION (r259151): The "Convert Text to Traditional Chinese" services menu action is broken
+            https://bugs.webkit.org/show_bug.cgi?id=219190
+            <rdar://problem/71438389>
+
+            Reviewed by Tim Horton.
+
+            Add an API test to exercise `-readSelectionFromPasteboard:`.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm:
+            (TEST):
+
 2020-11-02  Russell Epstein  <[email protected]>
 
         Cherry-pick r268199. rdar://problem/70952726

Modified: branches/safari-610-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm (270309 => 270310)


--- branches/safari-610-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm	2020-12-01 17:59:02 UTC (rev 270309)
+++ branches/safari-610-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm	2020-12-01 17:59:18 UTC (rev 270310)
@@ -45,6 +45,9 @@
 @end
 
 #if PLATFORM(MAC)
+@interface WKWebView () <NSServicesMenuRequestor>
+@end
+
 void writeHTMLToPasteboard(NSString *html)
 {
     [[NSPasteboard generalPasteboard] declareTypes:@[WebCore::legacyHTMLPasteboardType()] owner:nil];
@@ -387,6 +390,24 @@
         [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.body).fontFamily"]);
 }
 
+#if PLATFORM(MAC)
+
+TEST(PasteHTML, ReadSelectionFromPasteboard)
+{
+    auto generalPasteboard = NSPasteboard.generalPasteboard;
+    [generalPasteboard clearContents];
+    [generalPasteboard setString:@"Hello world" forType:NSPasteboardTypeString];
+
+    auto webView = createWebViewWithCustomPasteboardDataSetting(true);
+    [webView synchronouslyLoadHTMLString:@"<input autofocus>"];
+    [webView readSelectionFromPasteboard:generalPasteboard];
+
+    NSString *inputValue = [webView stringByEvaluatingJavaScript:@"document.querySelector('input').value"];
+    EXPECT_WK_STREQ(inputValue, "Hello world");
+}
+
+#endif // PLATFORM(MAC)
+
 #if ENABLE(DARK_MODE_CSS) && HAVE(OS_DARK_MODE_SUPPORT)
 
 TEST(PasteHTML, TransformColorsOfDarkContent)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to