Skip to content

Commit

Permalink
Remove mime restriction of plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedor committed May 4, 2024
1 parent e7eb1bb commit c36eb2f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 65 deletions.
6 changes: 0 additions & 6 deletions docshell/base/nsWebNavigationInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
return rv;
}

// As of FF 52, we only support flash and test plugins, so if the mime types
// don't match for that, exit before we start loading plugins.
if (!nsPluginHost::CanUsePluginForMIMEType(aType)) {
return NS_OK;
}

// If this request is for a docShell that isn't going to allow plugins,
// there's no need to try and find a plugin to handle it.
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav));
Expand Down
53 changes: 0 additions & 53 deletions dom/plugins/base/nsPluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,12 +1153,6 @@ nsPluginTag* nsPluginHost::FindNativePluginForType(const nsACString& aMimeType,
return nullptr;
}

// As of FF 52, we only support flash and test plugins, so if the mime types
// don't match for that, exit before we start loading plugins.
if (!nsPluginHost::CanUsePluginForMIMEType(aMimeType)) {
return nullptr;
}

LoadPlugins();

nsTArray<nsPluginTag*> matchingPlugins;
Expand Down Expand Up @@ -1432,29 +1426,6 @@ nsresult nsPluginHost::EnumerateSiteData(const nsACString& domain,
return NS_OK;
}

static bool MimeTypeIsAllowedForFakePlugin(const nsString& aMimeType) {
static const char* const allowedFakePlugins[] = {
// Flash
"application/x-shockwave-flash",
// PDF
"application/pdf",
"application/vnd.adobe.pdf",
"application/vnd.adobe.pdfxml",
"application/vnd.adobe.x-mars",
"application/vnd.adobe.xdp+xml",
"application/vnd.adobe.xfdf",
"application/vnd.adobe.xfd+xml",
"application/vnd.fdf",
};

for (const auto allowed : allowedFakePlugins) {
if (aMimeType.EqualsASCII(allowed)) {
return true;
}
}
return false;
}

NS_IMETHODIMP
nsPluginHost::RegisterFakePlugin(JS::Handle<JS::Value> aInitDictionary,
JSContext* aCx, nsIFakePluginTag** aResult) {
Expand All @@ -1463,12 +1434,6 @@ nsPluginHost::RegisterFakePlugin(JS::Handle<JS::Value> aInitDictionary,
return NS_ERROR_FAILURE;
}

for (const FakePluginMimeEntry& mimeEntry : initDictionary.mMimeEntries) {
if (!MimeTypeIsAllowedForFakePlugin(mimeEntry.mType)) {
return NS_ERROR_FAILURE;
}
}

RefPtr<nsFakePluginTag> newTag;
nsresult rv = nsFakePluginTag::Create(initDictionary, getter_AddRefs(newTag));
NS_ENSURE_SUCCESS(rv, rv);
Expand Down Expand Up @@ -3683,24 +3648,6 @@ void nsPluginHost::DestroyRunningInstances(nsPluginTag* aPluginTag) {
}
}

/* static */
bool nsPluginHost::CanUsePluginForMIMEType(const nsACString& aMIMEType) {
// We only support flash as a plugin, so if the mime types don't match for
// those, exit before we start loading plugins.
//
// XXX: Remove test/java cases when bug 1351885 lands.
if (nsPluginHost::GetSpecialType(aMIMEType) ==
nsPluginHost::eSpecialType_Flash ||
MimeTypeIsAllowedForFakePlugin(NS_ConvertUTF8toUTF16(aMIMEType)) ||
aMIMEType.LowerCaseEqualsLiteral("application/x-test") ||
aMIMEType.LowerCaseEqualsLiteral("application/x-second-test") ||
aMIMEType.LowerCaseEqualsLiteral("application/x-third-test")) {
return true;
}

return false;
}

// Runnable that does an async destroy of a plugin.

class nsPluginDestroyRunnable
Expand Down
6 changes: 0 additions & 6 deletions dom/plugins/base/nsPluginHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,6 @@ class nsPluginHost final : public nsIPluginHost,
// Always returns false if plugin.load_in_parent_process.<mime> is not set.
static bool ShouldLoadTypeInParent(const nsACString& aMimeType);

/**
* Returns true if a plugin can be used to load the requested MIME type. Used
* for short circuiting before sending things to plugin code.
*/
static bool CanUsePluginForMIMEType(const nsACString& aMIMEType);

// checks whether aType is a type we recognize for potential special handling
enum SpecialType {
eSpecialType_None,
Expand Down

0 comments on commit c36eb2f

Please sign in to comment.