Match unsupported plugins based on domains and not origin
https://bugs.webkit.org/show_bug.cgi?id=183384
Reviewed by Chris Dumez.
Source/WebCore:
Move from an origin-keyed map to a vector of plugins.
We iterate through the vector and a match happens if the page host name ends with the provided matching domain.
This allows supporting rules for *.mydomain.com by passing 'mydomain.com'.
Covered by existing tests.
We are not testing subdomains like www.localhost since there is no support in our CI but this is tested through Unit tests.
* loader/EmptyClients.cpp:
* platform/URL.cpp:
(WebCore::URL::isMatchingDomain const):
* platform/URL.h:
* plugins/PluginData.h:
(WebCore::isSupportedPlugin):
(WebCore::SupportedPluginName::decode):
(WebCore::SupportedPluginName::encode const):
* plugins/PluginInfoProvider.h:
Source/WebKit:
Moved from a HashMap of plugins to a Vector of plugins since we cannot match exactly based on the origin.
* Scripts/webkit/messages.py:
* UIProcess/API/C/WKContext.cpp:
(WKContextAddSupportedPlugin):
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _addSupportedPlugin:named:withMimeTypes:withExtensions:]):
* UIProcess/Plugins/PluginInfoStore.cpp:
(WebKit::PluginInfoStore::isSupportedPlugin):
(WebKit::PluginInfoStore::supportedPluginNames):
(WebKit::PluginInfoStore::addSupportedPlugin):
* UIProcess/Plugins/PluginInfoStore.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::addSupportedPlugin):
* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::getPlugins):
* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.messages.in:
* WebProcess/Plugins/WebPluginInfoProvider.cpp:
(WebKit::WebPluginInfoProvider::getPluginInfo):
(WebKit::WebPluginInfoProvider::getWebVisiblePluginInfo):
* WebProcess/Plugins/WebPluginInfoProvider.h:
Source/WebKitLegacy/mac:
* WebCoreSupport/WebPluginInfoProvider.h:
* WebCoreSupport/WebPluginInfoProvider.mm:
(WebPluginInfoProvider::getPluginInfo):
(WebPluginInfoProvider::getWebVisiblePluginInfo):
Tools:
* TestWebKitAPI/Tests/WebCore/URL.cpp:
(TestWebKitAPI::TEST_F):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setPluginSupportedMode): Update to whitelist
localhost and not http://localhost:8080
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@229390 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index e7379bb..727aa25 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2018-03-07 Youenn Fablet <youenn@apple.com>
+
+ Match unsupported plugins based on domains and not origin
+ https://bugs.webkit.org/show_bug.cgi?id=183384
+
+ Reviewed by Chris Dumez.
+
+ Move from an origin-keyed map to a vector of plugins.
+ We iterate through the vector and a match happens if the page host name ends with the provided matching domain.
+ This allows supporting rules for *.mydomain.com by passing 'mydomain.com'.
+ Covered by existing tests.
+ We are not testing subdomains like www.localhost since there is no support in our CI but this is tested through Unit tests.
+
+ * loader/EmptyClients.cpp:
+ * platform/URL.cpp:
+ (WebCore::URL::isMatchingDomain const):
+ * platform/URL.h:
+ * plugins/PluginData.h:
+ (WebCore::isSupportedPlugin):
+ (WebCore::SupportedPluginName::decode):
+ (WebCore::SupportedPluginName::encode const):
+ * plugins/PluginInfoProvider.h:
+
2017-12-18 Youenn Fablet <youenn@apple.com>
Update to libwebrtc revision 4e70a72571dd26b85c2385e9c618e343428df5d3
diff --git a/Source/WebCore/loader/EmptyClients.cpp b/Source/WebCore/loader/EmptyClients.cpp
index 3386802..d8850ff 100644
--- a/Source/WebCore/loader/EmptyClients.cpp
+++ b/Source/WebCore/loader/EmptyClients.cpp
@@ -325,7 +325,7 @@
class EmptyPluginInfoProvider final : public PluginInfoProvider {
void refreshPlugins() final { };
- void getPluginInfo(Page&, Vector<PluginInfo>&, std::optional<SupportedPluginNames>&) final { }
+ void getPluginInfo(Page&, Vector<PluginInfo>&, std::optional<Vector<SupportedPluginName>>&) final { }
void getWebVisiblePluginInfo(Page&, Vector<PluginInfo>&) final { }
};
diff --git a/Source/WebCore/platform/URL.cpp b/Source/WebCore/platform/URL.cpp
index 597a56c..97d91f3 100644
--- a/Source/WebCore/platform/URL.cpp
+++ b/Source/WebCore/platform/URL.cpp
@@ -776,6 +776,22 @@
return true;
}
+bool URL::isMatchingDomain(const String& domain) const
+{
+ // We restrict it to HTTP for simplicity since we do not want to match data, blob or file based URLs.
+ if (isNull() || !protocolIsInHTTPFamily())
+ return false;
+
+ if (domain.isEmpty())
+ return true;
+
+ auto host = this->host();
+ if (!host.endsWith(domain))
+ return false;
+
+ return host.length() == domain.length() || host.characterAt(host.length() - domain.length() - 1) == '.';
+}
+
String encodeWithURLEscapeSequences(const String& input)
{
return percentEncodeCharacters(input, URLParser::isInUserInfoEncodeSet);
diff --git a/Source/WebCore/platform/URL.h b/Source/WebCore/platform/URL.h
index b8ed778..45a7b31 100644
--- a/Source/WebCore/platform/URL.h
+++ b/Source/WebCore/platform/URL.h
@@ -141,6 +141,8 @@
WEBCORE_EXPORT bool isBlankURL() const;
bool cannotBeABaseURL() const { return m_cannotBeABaseURL; }
+ WEBCORE_EXPORT bool isMatchingDomain(const String&) const;
+
WEBCORE_EXPORT bool setProtocol(const String&);
void setHost(const String&);
diff --git a/Source/WebCore/plugins/PluginData.h b/Source/WebCore/plugins/PluginData.h
index 690ba72..a9a9fff 100644
--- a/Source/WebCore/plugins/PluginData.h
+++ b/Source/WebCore/plugins/PluginData.h
@@ -20,7 +20,7 @@
#pragma once
-#include "SecurityOriginData.h"
+#include "URL.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
@@ -88,12 +88,12 @@
return result;
}
-struct SupportedPluginNames {
- HashSet<String> allOriginPlugins;
- HashMap<SecurityOriginData, HashSet<String>> originSpecificPlugins;
+struct SupportedPluginName {
+ String matchingDomain;
+ String pluginName;
template<class Encoder> void encode(Encoder&) const;
- template<class Decoder> static std::optional<SupportedPluginNames> decode(Decoder&);
+ template<class Decoder> static std::optional<SupportedPluginName> decode(Decoder&);
};
// FIXME: merge with PluginDatabase in the future
@@ -126,39 +126,35 @@
protected:
Page& m_page;
Vector<PluginInfo> m_plugins;
- std::optional<SupportedPluginNames> m_supportedPluginNames;
+ std::optional<Vector<SupportedPluginName>> m_supportedPluginNames;
};
-inline bool isSupportedPlugin(SupportedPluginNames& pluginNames, SecurityOriginData& origin, const String& pluginName)
+inline bool isSupportedPlugin(const Vector<SupportedPluginName>& pluginNames, const URL& pageURL, const String& pluginName)
{
- auto iterator = pluginNames.originSpecificPlugins.find(origin);
- if (iterator != pluginNames.originSpecificPlugins.end()) {
- if (iterator->value.contains(pluginName))
- return true;
- }
-
- return pluginNames.allOriginPlugins.contains(pluginName);
+ return pluginNames.findMatching([&] (auto&& plugin) {
+ return pageURL.isMatchingDomain(plugin.matchingDomain) && plugin.pluginName == pluginName;
+ }) != notFound;
}
-template<class Decoder> inline std::optional<SupportedPluginNames> SupportedPluginNames::decode(Decoder& decoder)
+template<class Decoder> inline std::optional<SupportedPluginName> SupportedPluginName::decode(Decoder& decoder)
{
- std::optional<HashSet<String>> allOriginPlugins;
- decoder >> allOriginPlugins;
- if (!allOriginPlugins)
+ std::optional<String> matchingDomain;
+ decoder >> matchingDomain;
+ if (!matchingDomain)
return std::nullopt;
- std::optional<HashMap<SecurityOriginData, HashSet<String>>> originSpecificPlugins;
- decoder >> originSpecificPlugins;
- if (!originSpecificPlugins)
+ std::optional<String> pluginName;
+ decoder >> pluginName;
+ if (!pluginName)
return std::nullopt;
- return SupportedPluginNames { WTFMove(allOriginPlugins.value()), WTFMove(originSpecificPlugins.value()) };
+ return SupportedPluginName { WTFMove(matchingDomain.value()), WTFMove(pluginName.value()) };
}
-template<class Encoder> inline void SupportedPluginNames::encode(Encoder& encoder) const
+template<class Encoder> inline void SupportedPluginName::encode(Encoder& encoder) const
{
- encoder << allOriginPlugins;
- encoder << originSpecificPlugins;
+ encoder << matchingDomain;
+ encoder << pluginName;
}
} // namespace WebCore
diff --git a/Source/WebCore/plugins/PluginInfoProvider.h b/Source/WebCore/plugins/PluginInfoProvider.h
index 6e05efb..b03cd2e 100644
--- a/Source/WebCore/plugins/PluginInfoProvider.h
+++ b/Source/WebCore/plugins/PluginInfoProvider.h
@@ -39,7 +39,7 @@
void addPage(Page&);
void removePage(Page&);
- virtual void getPluginInfo(Page&, Vector<PluginInfo>&, std::optional<SupportedPluginNames>&) = 0;
+ virtual void getPluginInfo(Page&, Vector<PluginInfo>&, std::optional<Vector<SupportedPluginName>>&) = 0;
virtual void getWebVisiblePluginInfo(Page&, Vector<PluginInfo>&) = 0;
private:
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 7ac5b43..32089ab 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,34 @@
+2018-03-07 Youenn Fablet <youenn@apple.com>
+
+ Match unsupported plugins based on domains and not origin
+ https://bugs.webkit.org/show_bug.cgi?id=183384
+
+ Reviewed by Chris Dumez.
+
+ Moved from a HashMap of plugins to a Vector of plugins since we cannot match exactly based on the origin.
+
+ * Scripts/webkit/messages.py:
+ * UIProcess/API/C/WKContext.cpp:
+ (WKContextAddSupportedPlugin):
+ * UIProcess/API/Cocoa/WKProcessPool.mm:
+ (-[WKProcessPool _addSupportedPlugin:named:withMimeTypes:withExtensions:]):
+ * UIProcess/Plugins/PluginInfoStore.cpp:
+ (WebKit::PluginInfoStore::isSupportedPlugin):
+ (WebKit::PluginInfoStore::supportedPluginNames):
+ (WebKit::PluginInfoStore::addSupportedPlugin):
+ * UIProcess/Plugins/PluginInfoStore.h:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::addSupportedPlugin):
+ * UIProcess/WebProcessPool.h:
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::getPlugins):
+ * UIProcess/WebProcessProxy.h:
+ * UIProcess/WebProcessProxy.messages.in:
+ * WebProcess/Plugins/WebPluginInfoProvider.cpp:
+ (WebKit::WebPluginInfoProvider::getPluginInfo):
+ (WebKit::WebPluginInfoProvider::getWebVisiblePluginInfo):
+ * WebProcess/Plugins/WebPluginInfoProvider.h:
+
2018-03-07 Brent Fulgham <bfulgham@apple.com>
REGRESSION (r229093): Media playback on Facebook and Hulu require mDNSResponder access
diff --git a/Source/WebKit/Scripts/webkit/messages.py b/Source/WebKit/Scripts/webkit/messages.py
index 4ba3adb..717c120 100644
--- a/Source/WebKit/Scripts/webkit/messages.py
+++ b/Source/WebKit/Scripts/webkit/messages.py
@@ -398,7 +398,7 @@
'WebCore::ShippingMethodUpdate': ['<WebCore/ApplePaySessionPaymentRequest.h>'],
'WebCore::ShouldNotifyWhenResolved': ['<WebCore/ServiceWorkerTypes.h>'],
'WebCore::ShouldSample': ['<WebCore/DiagnosticLoggingClient.h>'],
- 'WebCore::SupportedPluginNames': ['<WebCore/PluginData.h>'],
+ 'WebCore::SupportedPluginName': ['<WebCore/PluginData.h>'],
'WebCore::TextCheckingRequestData': ['<WebCore/TextChecking.h>'],
'WebCore::TextCheckingResult': ['<WebCore/TextCheckerClient.h>'],
'WebCore::TextIndicatorData': ['<WebCore/TextIndicator.h>'],
diff --git a/Source/WebKit/UIProcess/API/C/WKContext.cpp b/Source/WebKit/UIProcess/API/C/WKContext.cpp
index dee0a09..9f2bf64 100644
--- a/Source/WebKit/UIProcess/API/C/WKContext.cpp
+++ b/Source/WebKit/UIProcess/API/C/WKContext.cpp
@@ -621,7 +621,7 @@
return toImpl(contextRef)->storageProcessIdentifier();
}
-void WKContextAddSupportedPlugin(WKContextRef contextRef, WKStringRef originRef, WKStringRef nameRef, WKArrayRef mimeTypesRef, WKArrayRef extensionsRef)
+void WKContextAddSupportedPlugin(WKContextRef contextRef, WKStringRef domainRef, WKStringRef nameRef, WKArrayRef mimeTypesRef, WKArrayRef extensionsRef)
{
#if ENABLE(NETSCAPE_PLUGIN_API)
HashSet<String> mimeTypes;
@@ -634,10 +634,7 @@
for (size_t i = 0; i < count; ++i)
extensions.add(toWTFString(static_cast<WKStringRef>(WKArrayGetItemAtIndex(extensionsRef, i))));
- RefPtr<SecurityOrigin> origin;
- if (!WKStringIsEmpty(originRef))
- origin = SecurityOrigin::createFromString(toWTFString(originRef));
- toImpl(contextRef)->addSupportedPlugin(origin.get(), toWTFString(nameRef), WTFMove(mimeTypes), WTFMove(extensions));
+ toImpl(contextRef)->addSupportedPlugin(toWTFString(domainRef), toWTFString(nameRef), WTFMove(mimeTypes), WTFMove(extensions));
#endif
}
diff --git a/Source/WebKit/UIProcess/API/C/WKContextPrivate.h b/Source/WebKit/UIProcess/API/C/WKContextPrivate.h
index 06480e1..eca52d3 100644
--- a/Source/WebKit/UIProcess/API/C/WKContextPrivate.h
+++ b/Source/WebKit/UIProcess/API/C/WKContextPrivate.h
@@ -112,7 +112,7 @@
WK_EXPORT WKProcessID WKContextGetNetworkProcessIdentifier(WKContextRef context);
WK_EXPORT WKProcessID WKContextGetDatabaseProcessIdentifier(WKContextRef context);
-WK_EXPORT void WKContextAddSupportedPlugin(WKContextRef context, WKStringRef origin, WKStringRef name, WKArrayRef mimeTypes, WKArrayRef extensions);
+WK_EXPORT void WKContextAddSupportedPlugin(WKContextRef context, WKStringRef domain, WKStringRef name, WKArrayRef mimeTypes, WKArrayRef extensions);
WK_EXPORT void WKContextClearSupportedPlugins(WKContextRef context);
#ifdef __cplusplus
diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
index 5f0c326..1d6bbb1 100644
--- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
+++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
@@ -397,7 +397,7 @@
_processPool->setAutomationSession(automationSession ? automationSession->_session.get() : nullptr);
}
-- (void)_addSupportedPlugin:(NSString *) origin named:(NSString *) name withMimeTypes: (NSSet<NSString *> *) nsMimeTypes withExtensions: (NSSet<NSString *> *) nsExtensions
+- (void)_addSupportedPlugin:(NSString *) domain named:(NSString *) name withMimeTypes: (NSSet<NSString *> *) nsMimeTypes withExtensions: (NSSet<NSString *> *) nsExtensions
{
HashSet<String> mimeTypes;
for (NSString *mimeType in nsMimeTypes)
@@ -406,7 +406,7 @@
for (NSString *extension in nsExtensions)
extensions.add(extension);
- _processPool->addSupportedPlugin([origin length] ? WebCore::SecurityOrigin::createFromString(origin).ptr() : nullptr, name, WTFMove(mimeTypes), WTFMove(extensions));
+ _processPool->addSupportedPlugin(domain, name, WTFMove(mimeTypes), WTFMove(extensions));
}
- (void)_clearSupportedPlugins
diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
index 8d152b5..7b00eea 100644
--- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
+++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
@@ -72,7 +72,7 @@
- (void)_automationCapabilitiesDidChange WK_API_AVAILABLE(macosx(10.12), ios(10.0));
- (void)_setAutomationSession:(_WKAutomationSession *)automationSession WK_API_AVAILABLE(macosx(10.12), ios(10.0));
-- (void)_addSupportedPlugin:(NSString *) origin named:(NSString *) name withMimeTypes: (NSSet<NSString *> *) mimeTypes withExtensions: (NSSet<NSString *> *) extensions WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_addSupportedPlugin:(NSString *) domain named:(NSString *) name withMimeTypes: (NSSet<NSString *> *) mimeTypes withExtensions: (NSSet<NSString *> *) extensions WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_clearSupportedPlugins WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
// Test only. Should be called only while no web content processes are running.
diff --git a/Source/WebKit/UIProcess/Plugins/PluginInfoStore.cpp b/Source/WebKit/UIProcess/Plugins/PluginInfoStore.cpp
index 61c00ee..23db334 100644
--- a/Source/WebKit/UIProcess/Plugins/PluginInfoStore.cpp
+++ b/Source/WebKit/UIProcess/Plugins/PluginInfoStore.cpp
@@ -29,8 +29,9 @@
#if ENABLE(NETSCAPE_PLUGIN_API)
#include "PluginModuleInfo.h"
-#include <WebCore/URL.h>
#include <WebCore/MIMETypeRegistry.h>
+#include <WebCore/SecurityOrigin.h>
+#include <WebCore/URL.h>
#include <algorithm>
#include <wtf/ListHashSet.h>
#include <wtf/StdLibExtras.h>
@@ -214,53 +215,31 @@
bool PluginInfoStore::isSupportedPlugin(const String& mimeType, const URL& pluginURL, const String&, const URL& pageURL)
{
- // We check only pageURLString for consistency with WebProcess visible plugins.
+ // We check only pageURL for consistency with WebProcess visible plugins.
if (!m_supportedPlugins)
return true;
- for (auto& plugin : m_supportedPlugins->originSpecificPlugins.get(SecurityOriginData { pageURL.protocol().toString(), pageURL.host(), pageURL.port() })) {
- if (isSupportedPlugin(plugin, mimeType, pluginURL))
- return true;
- }
- for (auto& plugin : m_supportedPlugins->allOriginPlugins) {
- if (isSupportedPlugin(plugin, mimeType, pluginURL))
- return true;
- }
- return false;
+ return m_supportedPlugins->findMatching([&] (auto&& plugin) {
+ return pageURL.isMatchingDomain(plugin.matchingDomain) && isSupportedPlugin(plugin, mimeType, pluginURL);
+ }) != notFound;
}
-std::optional<SupportedPluginNames> PluginInfoStore::supportedPluginNames()
+std::optional<Vector<SupportedPluginName>> PluginInfoStore::supportedPluginNames()
{
if (!m_supportedPlugins)
return std::nullopt;
- HashSet<String> allOriginPlugins;
- for (auto& plugin : m_supportedPlugins->allOriginPlugins)
- allOriginPlugins.add(plugin.name);
-
- HashMap<SecurityOriginData, HashSet<String>> originSpecificPlugins;
- for (auto& keyValue : m_supportedPlugins->originSpecificPlugins) {
- HashSet<String> names;
- for (auto& plugin : keyValue.value)
- names.add(plugin.name);
- originSpecificPlugins.add(keyValue.key, WTFMove(names));
- }
- return SupportedPluginNames { WTFMove(allOriginPlugins), WTFMove(originSpecificPlugins) };
+ return WTF::map(*m_supportedPlugins, [] (auto&& item) {
+ return SupportedPluginName { item.matchingDomain, item.name };
+ });
}
-void PluginInfoStore::addSupportedPlugin(const SecurityOrigin* origin, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions)
+void PluginInfoStore::addSupportedPlugin(String&& domainName, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions)
{
if (!m_supportedPlugins)
- m_supportedPlugins = SupportedPlugins { };
+ m_supportedPlugins = Vector<SupportedPlugin> { };
- SupportedPlugin plugin { WTFMove(name), WTFMove(mimeTypes), WTFMove(extensions) };
- if (!origin) {
- m_supportedPlugins->allOriginPlugins.append(WTFMove(plugin));
- return;
- }
- m_supportedPlugins->originSpecificPlugins.ensure(SecurityOriginData::fromSecurityOrigin(*origin), [] {
- return Vector<SupportedPlugin> { };
- }).iterator->value.append(WTFMove(plugin));
+ m_supportedPlugins->append(SupportedPlugin { WTFMove(domainName), WTFMove(name), WTFMove(mimeTypes), WTFMove(extensions) });
}
PluginModuleInfo PluginInfoStore::infoForPluginWithPath(const String& pluginPath) const
diff --git a/Source/WebKit/UIProcess/Plugins/PluginInfoStore.h b/Source/WebKit/UIProcess/Plugins/PluginInfoStore.h
index d3a109f..2da1549 100644
--- a/Source/WebKit/UIProcess/Plugins/PluginInfoStore.h
+++ b/Source/WebKit/UIProcess/Plugins/PluginInfoStore.h
@@ -64,8 +64,8 @@
static PluginModuleLoadPolicy defaultLoadPolicyForPlugin(const PluginModuleInfo&);
bool isSupportedPlugin(const String& mimeType, const WebCore::URL& pluginURL, const String& frameURLString, const WebCore::URL& pageURL);
- std::optional<WebCore::SupportedPluginNames> supportedPluginNames();
- void addSupportedPlugin(const WebCore::SecurityOrigin*, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions);
+ std::optional<Vector<WebCore::SupportedPluginName>> supportedPluginNames();
+ void addSupportedPlugin(String&& matchingDomain, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions);
void clearSupportedPlugins() { m_supportedPlugins = std::nullopt; }
private:
@@ -97,17 +97,14 @@
bool m_pluginListIsUpToDate;
struct SupportedPlugin {
+ String matchingDomain;
String name;
HashSet<String> mimeTypes;
HashSet<String> extensions;
};
- struct SupportedPlugins {
- Vector<SupportedPlugin> allOriginPlugins;
- HashMap<WebCore::SecurityOriginData, Vector<SupportedPlugin>> originSpecificPlugins;
- };
static bool isSupportedPlugin(const SupportedPlugin&, const String& mimeType, const WebCore::URL& pluginURL);
- std::optional<SupportedPlugins> m_supportedPlugins;
+ std::optional<Vector<SupportedPlugin>> m_supportedPlugins;
};
} // namespace WebKit
diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp
index 3fcaf5a..53f99fb 100644
--- a/Source/WebKit/UIProcess/WebProcessPool.cpp
+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp
@@ -1793,12 +1793,12 @@
}
#endif
-void WebProcessPool::addSupportedPlugin(SecurityOrigin* origin, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions)
+void WebProcessPool::addSupportedPlugin(String&& matchingDomain, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions)
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- m_pluginInfoStore.addSupportedPlugin(origin, WTFMove(name), WTFMove(mimeTypes), WTFMove(extensions));
+ m_pluginInfoStore.addSupportedPlugin(WTFMove(matchingDomain), WTFMove(name), WTFMove(mimeTypes), WTFMove(extensions));
#else
- UNUSED_PARAM(origin);
+ UNUSED_PARAM(matchingDomain);
UNUSED_PARAM(name);
UNUSED_PARAM(mimeTypes);
UNUSED_PARAM(extensions);
diff --git a/Source/WebKit/UIProcess/WebProcessPool.h b/Source/WebKit/UIProcess/WebProcessPool.h
index 907ef7b..b8926ed 100644
--- a/Source/WebKit/UIProcess/WebProcessPool.h
+++ b/Source/WebKit/UIProcess/WebProcessPool.h
@@ -202,7 +202,7 @@
const HashMap<String, HashMap<String, HashMap<String, uint8_t>>>& pluginLoadClientPolicies() const { return m_pluginLoadClientPolicies; }
#endif
- void addSupportedPlugin(WebCore::SecurityOrigin*, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions);
+ void addSupportedPlugin(String&& matchingDomain, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions);
void clearSupportedPlugins();
ProcessID networkProcessIdentifier();
diff --git a/Source/WebKit/UIProcess/WebProcessProxy.cpp b/Source/WebKit/UIProcess/WebProcessProxy.cpp
index a1198b3..ae8b8fd 100644
--- a/Source/WebKit/UIProcess/WebProcessProxy.cpp
+++ b/Source/WebKit/UIProcess/WebProcessProxy.cpp
@@ -570,7 +570,7 @@
}
#if ENABLE(NETSCAPE_PLUGIN_API)
-void WebProcessProxy::getPlugins(bool refresh, Vector<PluginInfo>& plugins, Vector<PluginInfo>& applicationPlugins, std::optional<WebCore::SupportedPluginNames>& supportedPluginNames)
+void WebProcessProxy::getPlugins(bool refresh, Vector<PluginInfo>& plugins, Vector<PluginInfo>& applicationPlugins, std::optional<Vector<WebCore::SupportedPluginName>>& supportedPluginNames)
{
if (refresh)
m_processPool->pluginInfoStore().refresh();
diff --git a/Source/WebKit/UIProcess/WebProcessProxy.h b/Source/WebKit/UIProcess/WebProcessProxy.h
index 1b66540..697eb90 100644
--- a/Source/WebKit/UIProcess/WebProcessProxy.h
+++ b/Source/WebKit/UIProcess/WebProcessProxy.h
@@ -238,7 +238,7 @@
// Plugins
#if ENABLE(NETSCAPE_PLUGIN_API)
- void getPlugins(bool refresh, Vector<WebCore::PluginInfo>& plugins, Vector<WebCore::PluginInfo>& applicationPlugins, std::optional<WebCore::SupportedPluginNames>&);
+ void getPlugins(bool refresh, Vector<WebCore::PluginInfo>& plugins, Vector<WebCore::PluginInfo>& applicationPlugins, std::optional<Vector<WebCore::SupportedPluginName>>&);
#endif // ENABLE(NETSCAPE_PLUGIN_API)
#if ENABLE(NETSCAPE_PLUGIN_API)
void getPluginProcessConnection(uint64_t pluginProcessToken, Ref<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply>&&);
diff --git a/Source/WebKit/UIProcess/WebProcessProxy.messages.in b/Source/WebKit/UIProcess/WebProcessProxy.messages.in
index 7f809f8..98c712a 100644
--- a/Source/WebKit/UIProcess/WebProcessProxy.messages.in
+++ b/Source/WebKit/UIProcess/WebProcessProxy.messages.in
@@ -33,7 +33,7 @@
# Plugin messages.
#if ENABLE(NETSCAPE_PLUGIN_API)
- GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins, Vector<WebCore::PluginInfo> applicationPlugins, struct std::optional<WebCore::SupportedPluginNames> supportedPluginNames)
+ GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins, Vector<WebCore::PluginInfo> applicationPlugins, struct std::optional<Vector<WebCore::SupportedPluginName>> supportedPluginNames)
GetPluginProcessConnection(uint64_t pluginProcessToken) -> (IPC::Attachment connectionHandle, bool supportsAsynchronousInitialization) Delayed
#endif
GetNetworkProcessConnection() -> (IPC::Attachment connectionHandle) Delayed
diff --git a/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.cpp b/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.cpp
index d97c020..44889a0 100644
--- a/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.cpp
+++ b/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.cpp
@@ -35,7 +35,6 @@
#include <WebCore/FrameLoader.h>
#include <WebCore/MainFrame.h>
#include <WebCore/Page.h>
-#include <WebCore/SecurityOriginData.h>
#include <WebCore/SubframeLoader.h>
#include <wtf/text/StringHash.h>
@@ -97,7 +96,7 @@
#endif
}
-void WebPluginInfoProvider::getPluginInfo(Page& page, Vector<PluginInfo>& plugins, std::optional<SupportedPluginNames>& supportedPluginNames)
+void WebPluginInfoProvider::getPluginInfo(Page& page, Vector<PluginInfo>& plugins, std::optional<Vector<SupportedPluginName>>& supportedPluginNames)
{
#if ENABLE(NETSCAPE_PLUGIN_API)
populatePluginCache(page);
@@ -121,20 +120,19 @@
{
ASSERT_ARG(plugins, plugins.isEmpty());
- std::optional<WebCore::SupportedPluginNames> supportedPluginNames;
+ std::optional<Vector<WebCore::SupportedPluginName>> supportedPluginNames;
getPluginInfo(page, plugins, supportedPluginNames);
auto* document = page.mainFrame().document();
- auto* origin = document ? &document->securityOrigin(): nullptr;
- if (origin && supportedPluginNames) {
- auto originData = SecurityOriginData::fromSecurityOrigin(*origin);
+ if (document && supportedPluginNames) {
plugins.removeAllMatching([&] (auto& plugin) {
- return !isSupportedPlugin(*supportedPluginNames, originData, plugin.name);
+ return !isSupportedPlugin(*supportedPluginNames, document->url(), plugin.name);
});
}
#if PLATFORM(MAC)
+ auto* origin = document ? &document->securityOrigin(): nullptr;
if (origin && origin->isLocal())
return;
diff --git a/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.h b/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.h
index c5cb1d8..3f640f1 100644
--- a/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.h
+++ b/Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.h
@@ -45,7 +45,7 @@
private:
WebPluginInfoProvider();
- void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<WebCore::SupportedPluginNames>&) final;
+ void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<Vector<WebCore::SupportedPluginName>>&) final;
void getWebVisiblePluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&) final;
void refreshPlugins() override;
@@ -68,7 +68,7 @@
bool m_shouldRefreshPlugins { false };
Vector<WebCore::PluginInfo> m_cachedPlugins;
Vector<WebCore::PluginInfo> m_cachedApplicationPlugins;
- std::optional<WebCore::SupportedPluginNames> m_cachedSupportedPluginNames;
+ std::optional<Vector<WebCore::SupportedPluginName>> m_cachedSupportedPluginNames;
#endif
};
diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog
index 4d1398d..9365955 100644
--- a/Source/WebKitLegacy/mac/ChangeLog
+++ b/Source/WebKitLegacy/mac/ChangeLog
@@ -1,3 +1,15 @@
+2018-03-07 Youenn Fablet <youenn@apple.com>
+
+ Match unsupported plugins based on domains and not origin
+ https://bugs.webkit.org/show_bug.cgi?id=183384
+
+ Reviewed by Chris Dumez.
+
+ * WebCoreSupport/WebPluginInfoProvider.h:
+ * WebCoreSupport/WebPluginInfoProvider.mm:
+ (WebPluginInfoProvider::getPluginInfo):
+ (WebPluginInfoProvider::getWebVisiblePluginInfo):
+
2018-03-05 Andy Estes <aestes@apple.com>
[Mac] Teach WebCore::Pasteboard about file promise drags
diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.h b/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.h
index 4a91bab..3e695ee 100644
--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.h
+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.h
@@ -34,7 +34,7 @@
private:
void refreshPlugins() override;
- void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<WebCore::SupportedPluginNames>&) final;
+ void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<Vector<WebCore::SupportedPluginName>>&) final;
void getWebVisiblePluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&) final;
WebPluginInfoProvider();
diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.mm b/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.mm
index 982db72..cd58f82 100644
--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.mm
+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebPluginInfoProvider.mm
@@ -55,7 +55,7 @@
[[WebPluginDatabase sharedDatabaseIfExists] refresh];
}
-void WebPluginInfoProvider::getPluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& plugins, std::optional<SupportedPluginNames>&)
+void WebPluginInfoProvider::getPluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& plugins, std::optional<Vector<SupportedPluginName>>&)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
@@ -71,6 +71,6 @@
void WebPluginInfoProvider::getWebVisiblePluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& plugins)
{
- std::optional<SupportedPluginNames> supportedPluginNames;
+ std::optional<Vector<SupportedPluginName>> supportedPluginNames;
getPluginInfo(page, plugins, supportedPluginNames);
}
diff --git a/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.cpp b/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.cpp
index 8db9d09..dc8fab6 100644
--- a/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.cpp
+++ b/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.cpp
@@ -49,7 +49,7 @@
PluginDatabase::installedPlugins()->refresh();
}
-void WebPluginInfoProvider::getPluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& outPlugins, std::optional<WebCore::SupportedPluginNames>&)
+void WebPluginInfoProvider::getPluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& outPlugins, std::optional<Vector<WebCore::SupportedPluginName>>&)
{
const Vector<PluginPackage*>& plugins = PluginDatabase::installedPlugins()->plugins();
@@ -84,6 +84,6 @@
void WebPluginInfoProvider::getWebVisiblePluginInfo(WebCore::Page& page, Vector<WebCore::PluginInfo>& plugins)
{
- std::optional<WebCore::SupportedPluginNames> supportedPluginNames;
+ std::optional<Vector<WebCore::SupportedPluginName>> supportedPluginNames;
getPluginInfo(page, plugins, supportedPluginNames);
}
diff --git a/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.h b/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.h
index bbc9bdc..e7325ca 100644
--- a/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.h
+++ b/Source/WebKitLegacy/win/WebCoreSupport/WebPluginInfoProvider.h
@@ -36,7 +36,7 @@
private:
void refreshPlugins() final;
- void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<WebCore::SupportedPluginNames>&) final;
+ void getPluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&, std::optional<Vector<WebCore::SupportedPluginName>>&) final;
void getWebVisiblePluginInfo(WebCore::Page&, Vector<WebCore::PluginInfo>&) final;
#if PLATFORM(MAC)
void setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy, const String& host, const String& bundleIdentifier, const String& versionString) final;
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 0dd130c..8b00bdb 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,16 @@
+2018-03-07 Youenn Fablet <youenn@apple.com>
+
+ Match unsupported plugins based on domains and not origin
+ https://bugs.webkit.org/show_bug.cgi?id=183384
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/Tests/WebCore/URL.cpp:
+ (TestWebKitAPI::TEST_F):
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::setPluginSupportedMode): Update to whitelist
+ localhost and not http://localhost:8080
+
2018-03-07 Jonathan Bedard <jbedard@apple.com>
webkitpy: Allow apple_additions() to define additional ports
diff --git a/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp b/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp
index 7c788a7..e07b475 100644
--- a/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp
+++ b/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp
@@ -264,4 +264,32 @@
EXPECT_TRUE(URL::hostIsIPAddress("::123.45.67.89"));
}
+TEST_F(URLTest, HostIsMatchingDomain)
+{
+ URL url = createURL("http://www.webkit.org");
+
+ EXPECT_TRUE(url.isMatchingDomain(String { }));
+ EXPECT_TRUE(url.isMatchingDomain(emptyString()));
+ EXPECT_TRUE(url.isMatchingDomain(ASCIILiteral("org")));
+ EXPECT_TRUE(url.isMatchingDomain(ASCIILiteral("webkit.org")));
+ EXPECT_TRUE(url.isMatchingDomain(ASCIILiteral("www.webkit.org")));
+
+ EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("rg")));
+ EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral(".org")));
+ EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("ww.webkit.org")));
+ EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("http://www.webkit.org")));
+
+ url = createURL("file:///www.webkit.org");
+
+ EXPECT_FALSE(url.isMatchingDomain(String { }));
+ EXPECT_FALSE(url.isMatchingDomain(emptyString()));
+ EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("org")));
+ EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("webkit.org")));
+ EXPECT_FALSE(url.isMatchingDomain(ASCIILiteral("www.webkit.org")));
+
+ URL emptyURL;
+ EXPECT_FALSE(emptyURL.isMatchingDomain(String { }));
+ EXPECT_FALSE(emptyURL.isMatchingDomain(emptyString()));
+}
+
} // namespace TestWebKitAPI
diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp
index cf50801..3fae217 100644
--- a/Tools/WebKitTestRunner/TestController.cpp
+++ b/Tools/WebKitTestRunner/TestController.cpp
@@ -1703,7 +1703,7 @@
WKRetainPtr<WKMutableArrayRef> emptyArray = adoptWK(WKMutableArrayCreate());
WKRetainPtr<WKStringRef> allOrigins = adoptWK(WKStringCreateWithUTF8CString(""));
- WKRetainPtr<WKStringRef> specificOrigin = adoptWK(WKStringCreateWithUTF8CString("http://localhost:8080"));
+ WKRetainPtr<WKStringRef> specificOrigin = adoptWK(WKStringCreateWithUTF8CString("localhost"));
WKRetainPtr<WKStringRef> pdfName = adoptWK(WKStringCreateWithUTF8CString("My personal PDF"));
WKContextAddSupportedPlugin(m_context.get(), allOrigins.get(), pdfName.get(), emptyArray.get(), emptyArray.get());