Bug 306471 part 2 - Do not query handler service for content-type of file extension. r=bz
MozReview-Commit-ID: FP1J6Qk3fsM
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -2723,44 +2723,36 @@ NS_IMETHODIMP nsExternalHelperAppService
}
NS_IMETHODIMP
nsExternalHelperAppService::GetTypeFromExtension(const nsACString& aFileExt,
nsACString& aContentType)
{
// OK. We want to try the following sources of mimetype information, in this order:
// 1. defaultMimeEntries array
- // 2. User-set preferences (managed by the handler service)
- // 3. OS-provided information
- // 4. our "extras" array
- // 5. Information from plugins
- // 6. The "ext-to-type-mapping" category
+ // 2. OS-provided information
+ // 3. our "extras" array
+ // 4. Information from plugins
+ // 5. The "ext-to-type-mapping" category
+ // Note that, we are intentionally not looking at the handler service, because
+ // that can be affected by websites, which leads to undesired behavior.
// Early return if called with an empty extension parameter
if (aFileExt.IsEmpty()) {
return NS_ERROR_NOT_AVAILABLE;
}
// First of all, check our default entries
for (auto& entry : defaultMimeEntries) {
if (aFileExt.LowerCaseEqualsASCII(entry.mFileExtension)) {
aContentType = entry.mMimeType;
return NS_OK;
}
}
- // Check user-set prefs
- nsCOMPtr<nsIHandlerService> handlerSvc = do_GetService(NS_HANDLERSERVICE_CONTRACTID);
- if (handlerSvc) {
- nsresult rv = handlerSvc->GetTypeFromExtension(aFileExt, aContentType);
- if (NS_SUCCEEDED(rv) && !aContentType.IsEmpty()) {
- return NS_OK;
- }
- }
-
// Ask OS.
bool found = false;
nsCOMPtr<nsIMIMEInfo> mi = GetMIMEInfoFromOS(EmptyCString(), aFileExt, &found);
if (mi && found) {
return mi->GetMIMEType(aContentType);
}
// Check extras array.