зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1463809 - Don't lookup mimeinfo of application/octet-stream; r=Paolo
Mimeinfo returned for the generic application/octet-stream content type is usually irrelevant to the file extension, getting mimeinfo from extension itself is more reliable. Also prefer file extension over application/octet-stream content tyope when lookup in extras. MozReview-Commit-ID: A9Q2NFAwQ7b --HG-- extra : rebase_source : 4206cbfd898fb12b2415ef751a74d1bdeee26a2d
This commit is contained in:
Родитель
d100a75344
Коммит
cb8d3c752f
|
@ -2595,16 +2595,11 @@ NS_IMETHODIMP nsExternalHelperAppService::GetFromTypeAndExtension(const nsACStri
|
|||
// (3) No match yet. Ask extras.
|
||||
if (!found) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
#ifdef XP_WIN
|
||||
/* XXX Gross hack to wallpaper over the most common Win32
|
||||
* extension issues caused by the fix for bug 116938. See bug
|
||||
* 120327, comment 271 for why this is needed. Not even sure we
|
||||
* want to remove this once we have fixed all this stuff to work
|
||||
* right; any info we get from extras on this type is pretty much
|
||||
* useless....
|
||||
*/
|
||||
// Getting info for application/octet-stream content-type from extras
|
||||
// does not make a sense because this tends to open all octet-streams
|
||||
// as Binary file with exe, com or bin extension regardless the real
|
||||
// extension.
|
||||
if (!typeToUse.Equals(APPLICATION_OCTET_STREAM, nsCaseInsensitiveCStringComparator()))
|
||||
#endif
|
||||
rv = FillMIMEInfoForMimeTypeFromExtras(typeToUse, *_retval);
|
||||
LOG(("Searched extras (by type), rv 0x%08" PRIX32 "\n", static_cast<uint32_t>(rv)));
|
||||
// If that didn't work out, try file extension from extras
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "prenv.h" // for PR_GetEnv()
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -1450,7 +1451,12 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aType,
|
|||
const nsACString& aFileExt,
|
||||
bool *aFound) {
|
||||
*aFound = true;
|
||||
RefPtr<nsMIMEInfoBase> retval = GetFromType(PromiseFlatCString(aType));
|
||||
RefPtr<nsMIMEInfoBase> retval;
|
||||
// Fallback to lookup by extension when generic 'application/octet-stream'
|
||||
// content type is received.
|
||||
if (!aType.EqualsLiteral(APPLICATION_OCTET_STREAM)) {
|
||||
retval = GetFromType(PromiseFlatCString(aType));
|
||||
}
|
||||
bool hasDefault = false;
|
||||
if (retval)
|
||||
retval->GetHasDefaultHandler(&hasDefault);
|
||||
|
|
Загрузка…
Ссылка в новой задаче