Changeset 270072 in webkit


Ignore:
Timestamp:
Nov 19, 2020 11:33:31 PM (3 years ago)
Author:
Wenson Hsieh
Message:

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):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r270071 r270072  
     12020-11-19  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        REGRESSION (r259151): The "Convert Text to Traditional Chinese" services menu action is broken
     4        https://bugs.webkit.org/show_bug.cgi?id=219190
     5        <rdar://problem/71438389>
     6
     7        Reviewed by Tim Horton.
     8
     9        Some system services, such as "Convert Text to (Traditional|Simplified) Chinese", use `-[NSServicesMenuRequestor
     10        readSelectionFromPasteboard:]` to insert the contents of the given pasteboard into the current selection. After
     11        the changes in r259151, this requires the UI process to explicitly grant access to the contents of the given
     12        pasteboard, on behalf of the web content process.
     13
     14        Fix the bug by adding the missing call to `grantAccessToCurrentPasteboardData`. This is only called from API in
     15        the UI process, so it cannot be abused by a compromised web content process to grab the contents of
     16        `NSPasteboard`.
     17
     18        Test: PasteHTML.ReadSelectionFromPasteboard
     19
     20        * UIProcess/mac/WebPageProxyMac.mm:
     21        (WebKit::WebPageProxy::readSelectionFromPasteboard):
     22
    1232020-11-19  Fujii Hironori  <Hironori.Fujii@sony.com>
    224
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r269805 r270072  
    272272        return false;
    273273
     274    grantAccessToCurrentPasteboardData(pasteboardName);
     275
    274276    bool result = false;
    275277    const Seconds messageTimeout(20);
  • trunk/Tools/ChangeLog

    r270069 r270072  
     12020-11-19  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        REGRESSION (r259151): The "Convert Text to Traditional Chinese" services menu action is broken
     4        https://bugs.webkit.org/show_bug.cgi?id=219190
     5        <rdar://problem/71438389>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add an API test to exercise `-readSelectionFromPasteboard:`.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm:
     12        (TEST):
     13
    1142020-11-19  Hoa Dinh  <dvh@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm

    r260366 r270072  
    4646
    4747#if PLATFORM(MAC)
     48@interface WKWebView () <NSServicesMenuRequestor>
     49@end
     50
    4851void writeHTMLToPasteboard(NSString *html)
    4952{
     
    388391}
    389392
     393#if PLATFORM(MAC)
     394
     395TEST(PasteHTML, ReadSelectionFromPasteboard)
     396{
     397    auto generalPasteboard = NSPasteboard.generalPasteboard;
     398    [generalPasteboard clearContents];
     399    [generalPasteboard setString:@"Hello world" forType:NSPasteboardTypeString];
     400
     401    auto webView = createWebViewWithCustomPasteboardDataSetting(true);
     402    [webView synchronouslyLoadHTMLString:@"<input autofocus>"];
     403    [webView readSelectionFromPasteboard:generalPasteboard];
     404
     405    NSString *inputValue = [webView stringByEvaluatingJavaScript:@"document.querySelector('input').value"];
     406    EXPECT_WK_STREQ(inputValue, "Hello world");
     407}
     408
     409#endif // PLATFORM(MAC)
     410
    390411#if ENABLE(DARK_MODE_CSS) && HAVE(OS_DARK_MODE_SUPPORT)
    391412
Note: See TracChangeset for help on using the changeset viewer.