Changeset 271650 in webkit
- Timestamp:
- Jan 20, 2021 9:44:15 AM (18 months ago)
- Location:
- trunk
- Files:
-
- 12 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/HTMLPlugInImageElement.cpp (modified) (3 diffs)
-
Source/WebCore/html/HTMLPlugInImageElement.h (modified) (1 diff)
-
Source/WebCore/loader/FrameLoaderClient.h (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/WebPage.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/WebPage.h (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKPDFView.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r271648 r271650 1 2021-01-20 Kate Cheney <katherine_cheney@apple.com> 2 3 Safari says "Blocked Plug-in" instead showing a PDF 4 https://bugs.webkit.org/show_bug.cgi?id=220665 5 <rdar://problem/64372944> 6 7 Reviewed by Darin Adler. 8 9 WebKit's PDFPlugin is a browser implementation detail and should 10 bypass the ContentSecurityPolicy::allowObjectFromSource() check 11 in order to not be blocked along with other plugins. 12 13 * html/HTMLPlugInImageElement.cpp: 14 (WebCore::HTMLPlugInImageElement::shouldBypassCSPForPDFPlugin const): 15 The check for whether to use PDFPlugin happens in 16 WebPage::createPlugin(). Some information there like isUnsupported, 17 isBlockedPlugin and pluginProcessToken are sent from the UIProcess 18 after the CSP check so they are unavailable here, but we know that PDFPlugin 19 will always be used when plugins are disabled and can use that information 20 to know whether to bypass CSP here in many cases. This will not relax 21 CSP or change behavior in other cases. 22 23 It would be ideal to check for an alternative PDF plugin in the case 24 where plugins are not disabled, but this information currently lives 25 in the UIProcess and is not sent to the WebProcess until after this 26 check. This patch will definitely fix Safari, where plugins are always disabled. 27 28 (WebCore::HTMLPlugInImageElement::canLoadPlugInContent const): 29 * html/HTMLPlugInImageElement.h: 30 * loader/FrameLoaderClient.h: 31 1 32 2021-01-20 Rob Buis <rbuis@igalia.com> 2 33 -
trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp
r269785 r271650 26 26 #include "CommonVM.h" 27 27 #include "ContentSecurityPolicy.h" 28 #include "DocumentLoader.h" 28 29 #include "EventNames.h" 29 30 #include "Frame.h" … … 269 270 } 270 271 272 bool HTMLPlugInImageElement::shouldBypassCSPForPDFPlugin(const String& contentType) const 273 { 274 #if ENABLE(PDFKIT_PLUGIN) 275 // We only consider bypassing this CSP check if plugins are disabled. In that case we know that 276 // any plugin used is a browser implementation detail. It is not safe to skip this check 277 // if plugins are enabled in case an external plugin is used to load PDF content. 278 // FIXME: Check for alternative PDF plugins here so we can bypass this CSP check for PDFPlugin even when plugins are enabled. 279 if (document().frame()->arePluginsEnabled()) 280 return false; 281 282 return document().frame()->loader().client().shouldUsePDFPlugin(contentType, document().url().path()); 283 #else 284 UNUSED_PARAM(contentType); 285 return false; 286 #endif 287 } 288 271 289 bool HTMLPlugInImageElement::canLoadPlugInContent(const String& relativeURL, const String& mimeType) const 272 290 { … … 284 302 contentSecurityPolicy.upgradeInsecureRequestIfNeeded(completedURL, ContentSecurityPolicy::InsecureRequestType::Load); 285 303 286 if (! contentSecurityPolicy.allowObjectFromSource(completedURL))304 if (!shouldBypassCSPForPDFPlugin(mimeType) && !contentSecurityPolicy.allowObjectFromSource(completedURL)) 287 305 return false; 288 306 -
trunk/Source/WebCore/html/HTMLPlugInImageElement.h
r269785 r271650 69 69 bool isPlugInImageElement() const final { return true; } 70 70 71 bool shouldBypassCSPForPDFPlugin(const String&) const; 71 72 bool canLoadPlugInContent(const String& relativeURL, const String& mimeType) const; 72 73 bool canLoadURL(const URL&) const; -
trunk/Source/WebCore/loader/FrameLoaderClient.h
r271378 r271650 381 381 virtual void notifyPageOfAppBoundBehavior() { } 382 382 #endif 383 384 #if ENABLE(PDFKIT_PLUGIN) 385 virtual bool shouldUsePDFPlugin(const String&, StringView) const { return false; } 386 #endif 383 387 }; 384 388 -
trunk/Source/WebKit/ChangeLog
r271647 r271650 1 2021-01-20 Kate Cheney <katherine_cheney@apple.com> 2 3 Safari says "Blocked Plug-in" instead showing a PDF 4 https://bugs.webkit.org/show_bug.cgi?id=220665 5 <rdar://problem/64372944> 6 7 Reviewed by Darin Adler. 8 9 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 10 (WebKit::WebFrameLoaderClient::shouldUsePDFPlugin const): 11 * WebProcess/WebCoreSupport/WebFrameLoaderClient.h: 12 * WebProcess/WebPage/WebPage.cpp: 13 (WebKit::WebPage::createPlugin): 14 * WebProcess/WebPage/WebPage.h: 15 * WebProcess/WebPage/mac/WebPageMac.mm: 16 (WebKit::WebPage::shouldUsePDFPlugin const): 17 1 18 2021-01-20 Michael Catanzaro <mcatanzaro@gnome.org> 2 19 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r271378 r271650 1949 1949 #endif 1950 1950 1951 #if ENABLE(PDFKIT_PLUGIN) 1952 bool WebFrameLoaderClient::shouldUsePDFPlugin(const String& contentType, StringView path) const 1953 { 1954 auto* page = m_frame->page(); 1955 return page && page->shouldUsePDFPlugin(contentType, path); 1956 } 1957 #endif 1958 1951 1959 } // namespace WebKit 1952 1960 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
r271378 r271650 290 290 void notifyPageOfAppBoundBehavior() final; 291 291 #endif 292 293 #if ENABLE(PDFKIT_PLUGIN) 294 bool shouldUsePDFPlugin(const String& contentType, StringView path) const final; 295 #endif 296 292 297 }; 293 298 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r271469 r271650 1083 1083 if (isUnsupported || isBlockedPlugin || !pluginProcessToken) { 1084 1084 #if ENABLE(PDFKIT_PLUGIN) 1085 auto path = parameters.url.path(); 1086 if (shouldUsePDFPlugin() && (MIMETypeRegistry::isPDFOrPostScriptMIMEType(parameters.mimeType) || (parameters.mimeType.isEmpty() && (path.endsWithIgnoringASCIICase(".pdf") || path.endsWithIgnoringASCIICase(".ps"))))) 1085 if (shouldUsePDFPlugin(parameters.mimeType, parameters.url.path())) 1087 1086 return PDFPlugin::create(*frame); 1088 1087 #endif -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r271469 r271650 1084 1084 1085 1085 #if PLATFORM(COCOA) 1086 bool shouldUsePDFPlugin() const;1087 1086 bool pdfPluginEnabled() const { return m_pdfPluginEnabled; } 1088 1087 void setPDFPluginEnabled(bool enabled) { m_pdfPluginEnabled = enabled; } … … 1379 1378 1380 1379 void dispatchWheelEventWithoutScrolling(const WebWheelEvent&, CompletionHandler<void(bool)>&&); 1380 1381 #if ENABLE(PDFKIT_PLUGIN) 1382 bool shouldUsePDFPlugin(const String& contentType, StringView path) const; 1383 #endif 1381 1384 1382 1385 private: -
trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
r271459 r271650 197 197 } 198 198 199 bool WebPage::shouldUsePDFPlugin() const 200 { 201 return pdfPluginEnabled() && classFromPDFKit(@"PDFLayerController"); 199 bool WebPage::shouldUsePDFPlugin(const String& contentType, StringView path) const 200 { 201 return pdfPluginEnabled() 202 && classFromPDFKit(@"PDFLayerController") 203 && (MIMETypeRegistry::isPDFOrPostScriptMIMEType(contentType) 204 || (contentType.isEmpty() 205 && (path.endsWithIgnoringASCIICase(".pdf") || path.endsWithIgnoringASCIICase(".ps")))); 202 206 } 203 207 -
trunk/Tools/ChangeLog
r271649 r271650 1 2021-01-20 Kate Cheney <katherine_cheney@apple.com> 2 3 Safari says "Blocked Plug-in" instead showing a PDF 4 https://bugs.webkit.org/show_bug.cgi?id=220665 5 <rdar://problem/64372944> 6 7 Reviewed by Darin Adler. 8 9 API test coverage. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/WKPDFView.mm: 12 (TEST): 13 1 14 2021-01-20 Jonathan Bedard <jbedard@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKPDFView.mm
r270592 r271650 34 34 #import "TestURLSchemeHandler.h" 35 35 #import "TestWKWebView.h" 36 #import <WebKit/WKProcessPoolPrivate.h> 36 37 #import <WebKit/WKWebView.h> 37 38 #import <WebKit/WKWebViewConfigurationPrivate.h> … … 360 361 } 361 362 362 #endif 363 TEST(PDFHUD, LoadPDFTypeWithPluginsBlocked) 364 { 365 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 366 [configuration _setOverrideContentSecurityPolicy:@"object-src 'none'"]; 367 TestWKWebView *webView = [[[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()] autorelease]; 368 [webView loadData:pdfData() MIMEType:@"application/pdf" characterEncodingName:@"" baseURL:[NSURL URLWithString:@"https://www.apple.com/testPath"]]; 369 EXPECT_EQ(webView._pdfHUDs.count, 0u); 370 [webView _test_waitForDidFinishNavigation]; 371 EXPECT_EQ(webView._pdfHUDs.count, 1u); 372 checkFrame(webView._pdfHUDs.anyObject.frame, 0, 0, 800, 600); 373 } 374 375 #endif
Note: See TracChangeset
for help on using the changeset viewer.