Unverified Commit 6bfc2043 authored by Matthew Finkel's avatar Matthew Finkel
Browse files

Bug 40432: Prevent probing installed applications

parent 02a2e317
...@@ -1049,8 +1049,33 @@ nsresult nsExternalHelperAppService::GetFileTokenForPath( ...@@ -1049,8 +1049,33 @@ nsresult nsExternalHelperAppService::GetFileTokenForPath(
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
// begin external protocol service default implementation... // begin external protocol service default implementation...
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
static const char kExternalProtocolPrefPrefix[] =
"network.protocol-handler.external.";
static const char kExternalProtocolDefaultPref[] =
"network.protocol-handler.external-default";
NS_IMETHODIMP nsExternalHelperAppService::ExternalProtocolHandlerExists( NS_IMETHODIMP nsExternalHelperAppService::ExternalProtocolHandlerExists(
const char* aProtocolScheme, bool* aHandlerExists) { const char* aProtocolScheme, bool* aHandlerExists) {
// Replicate the same check performed in LoadURI.
// Deny load if the prefs say to do so
nsAutoCString externalPref(kExternalProtocolPrefPrefix);
externalPref += aProtocolScheme;
bool allowLoad = false;
*aHandlerExists = false;
if (NS_FAILED(Preferences::GetBool(externalPref.get(), &allowLoad))) {
// no scheme-specific value, check the default
if (NS_FAILED(
Preferences::GetBool(kExternalProtocolDefaultPref, &allowLoad))) {
return NS_OK; // missing default pref
}
}
if (!allowLoad) {
return NS_OK; // explicitly denied
}
nsCOMPtr<nsIHandlerInfo> handlerInfo; nsCOMPtr<nsIHandlerInfo> handlerInfo;
nsresult rv = GetProtocolHandlerInfo(nsDependentCString(aProtocolScheme), nsresult rv = GetProtocolHandlerInfo(nsDependentCString(aProtocolScheme),
getter_AddRefs(handlerInfo)); getter_AddRefs(handlerInfo));
...@@ -1093,11 +1118,6 @@ NS_IMETHODIMP nsExternalHelperAppService::IsExposedProtocol( ...@@ -1093,11 +1118,6 @@ NS_IMETHODIMP nsExternalHelperAppService::IsExposedProtocol(
return NS_OK; return NS_OK;
} }
static const char kExternalProtocolPrefPrefix[] =
"network.protocol-handler.external.";
static const char kExternalProtocolDefaultPref[] =
"network.protocol-handler.external-default";
NS_IMETHODIMP NS_IMETHODIMP
nsExternalHelperAppService::LoadURI(nsIURI* aURI, nsExternalHelperAppService::LoadURI(nsIURI* aURI,
nsIPrincipal* aTriggeringPrincipal, nsIPrincipal* aTriggeringPrincipal,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment