author | Cosmin Sabou <csabou@mozilla.com> |
Thu, 20 Aug 2020 06:20:21 +0300 | |
changeset 610106 | 8cb700c12bd3acfdef56ce084c87d64fa4daae03 |
parent 610105 | b02450ca3c472c6c9e3c9000f8a52dbf7144411c |
child 610107 | ef845528f330698a7de7325563fff317e410640e |
push id | 13553 |
push user | ffxbld-merge |
push date | Mon, 24 Aug 2020 12:51:36 +0000 |
treeherder | mozilla-beta@a54f8b5d0977 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1571247 |
milestone | 81.0a1 |
backs out | 4d700219feabe7943055b2db80090afe7d4fe19a |
first release with | nightly linux32
8cb700c12bd3
/
81.0a1
/
20200820093209
/
files
nightly linux64
8cb700c12bd3
/
81.0a1
/
20200820093209
/
files
nightly mac
8cb700c12bd3
/
81.0a1
/
20200820093209
/
files
nightly win32
8cb700c12bd3
/
81.0a1
/
20200820093209
/
files
nightly win64
8cb700c12bd3
/
81.0a1
/
20200820093209
/
files
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
releases | nightly linux32
81.0a1
/
20200820093209
/
pushlog to previous
nightly linux64
81.0a1
/
20200820093209
/
pushlog to previous
nightly mac
81.0a1
/
20200820093209
/
pushlog to previous
nightly win32
81.0a1
/
20200820093209
/
pushlog to previous
nightly win64
81.0a1
/
20200820093209
/
pushlog to previous
|
uriloader/exthandler/nsExternalHelperAppService.cpp | file | annotate | diff | comparison | revisions | |
uriloader/exthandler/nsExternalHelperAppService.h | file | annotate | diff | comparison | revisions |
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -482,17 +482,17 @@ static const nsExtraMimeTypeEntry extraM #endif // Note: if you add new image types, please also update the list in // contentAreaUtils.js to match. {IMAGE_ART, "art", "ART Image"}, {IMAGE_BMP, "bmp", "BMP Image"}, {IMAGE_GIF, "gif", "GIF Image"}, {IMAGE_ICO, "ico,cur", "ICO Image"}, - {IMAGE_JPEG, "jpg,jpeg,jfif,pjpeg,pjp", "JPEG Image"}, + {IMAGE_JPEG, "jpeg,jpg,jfif,pjpeg,pjp", "JPEG Image"}, {IMAGE_PNG, "png", "PNG Image"}, {IMAGE_APNG, "apng", "APNG Image"}, {IMAGE_TIFF, "tiff,tif", "TIFF Image"}, {IMAGE_XBM, "xbm", "XBM Image"}, {IMAGE_SVG_XML, "svg", "Scalable Vector Graphics"}, {IMAGE_WEBP, "webp", "WebP Image"}, {IMAGE_AVIF, "avif", "AV1 Image File"}, @@ -523,19 +523,16 @@ static const nsExtraMimeTypeEntry extraM {AUDIO_WAV, "wav", "Waveform Audio"}, {VIDEO_3GPP, "3gpp,3gp", "3GPP Video"}, {VIDEO_3GPP2, "3g2", "3GPP2 Video"}, {AUDIO_AAC, "aac", "AAC Audio"}, {AUDIO_FLAC, "flac", "FLAC Audio"}, {AUDIO_MIDI, "mid", "Standard MIDI Audio"}, {APPLICATION_WASM, "wasm", "WebAssembly Module"}}; -static const nsDefaultMimeTypeEntry sForbiddenPrimaryExtensions[] = { - {IMAGE_JPEG, "jfif"}}; - /** * File extensions for which decoding should be disabled. * NOTE: These MUST be lower-case and ASCII. */ static const nsDefaultMimeTypeEntry nonDecodableExtensions[] = { {APPLICATION_GZIP, "gz"}, {APPLICATION_GZIP, "tgz"}, {APPLICATION_ZIP, "zip"}, @@ -2629,47 +2626,36 @@ NS_IMETHODIMP nsExternalHelperAppService if (!found && !aFileExt.IsEmpty()) { // XXXzpao This should probably be localized nsAutoCString desc(aFileExt); desc.AppendLiteral(" File"); (*_retval)->SetDescription(NS_ConvertASCIItoUTF16(desc)); LOG(("Falling back to 'File' file description\n")); } - // Sometimes, OSes give us bad data. We have a set of forbidden extensions - // for some MIME types. If the primary extension is forbidden, - // overwrite it with a known-good one. See bug 1571247 for context. - nsAutoCString primaryExtension; - (*_retval)->GetPrimaryExtension(primaryExtension); - if (!primaryExtension.LowerCaseEqualsASCII( - PromiseFlatCString(aFileExt).get())) { - if (MaybeReplacePrimaryExtension(primaryExtension, *_retval)) { - (*_retval)->GetPrimaryExtension(primaryExtension); - } - } - // Finally, check if we got a file extension and if yes, if it is an // extension on the mimeinfo, in which case we want it to be the primary one if (!aFileExt.IsEmpty()) { bool matches = false; (*_retval)->ExtensionExists(aFileExt, &matches); LOG(("Extension '%s' matches mime info: %i\n", PromiseFlatCString(aFileExt).get(), matches)); if (matches) { nsAutoCString fileExt; ToLowerCase(aFileExt, fileExt); (*_retval)->SetPrimaryExtension(fileExt); - primaryExtension = fileExt; } } // Overwrite with a generic description if the primary extension for the // type is in our list; these are file formats supported by Firefox and // we don't want other brands positioning themselves as the sole viewer // for a system. + nsAutoCString primaryExtension; + rv = (*_retval)->GetPrimaryExtension(primaryExtension); if (NS_SUCCEEDED(rv)) { for (const char* ext : descriptionOverwriteExtensions) { if (primaryExtension.Equals(ext)) { nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIStringBundle> unknownContentTypeBundle; rv = bundleService->CreateBundle( @@ -2689,18 +2675,20 @@ NS_IMETHODIMP nsExternalHelperAppService } } } if (LOG_ENABLED()) { nsAutoCString type; (*_retval)->GetMIMEType(type); + nsAutoCString ext; + (*_retval)->GetPrimaryExtension(ext); LOG(("MIME Info Summary: Type '%s', Primary Ext '%s'\n", type.get(), - primaryExtension.get())); + ext.get())); } return NS_OK; } NS_IMETHODIMP nsExternalHelperAppService::GetTypeFromExtension(const nsACString& aFileExt, nsACString& aContentType) { @@ -2897,36 +2885,16 @@ nsresult nsExternalHelperAppService::Fil nsresult nsExternalHelperAppService::FillMIMEInfoForExtensionFromExtras( const nsACString& aExtension, nsIMIMEInfo* aMIMEInfo) { nsAutoCString type; bool found = GetTypeFromExtras(aExtension, type); if (!found) return NS_ERROR_NOT_AVAILABLE; return FillMIMEInfoForMimeTypeFromExtras(type, true, aMIMEInfo); } -bool nsExternalHelperAppService::MaybeReplacePrimaryExtension( - const nsACString& aPrimaryExtension, nsIMIMEInfo* aMIMEInfo) { - for (const auto& entry : sForbiddenPrimaryExtensions) { - if (aPrimaryExtension.LowerCaseEqualsASCII(entry.mFileExtension)) { - nsDependentCString mime(entry.mMimeType); - for (const auto& extraEntry : extraMimeEntries) { - if (mime.LowerCaseEqualsASCII(extraEntry.mMimeType)) { - nsDependentCString goodExts(extraEntry.mFileExtensions); - int32_t commaPos = goodExts.FindChar(','); - commaPos = commaPos == kNotFound ? goodExts.Length() : commaPos; - auto goodExt = Substring(goodExts, 0, commaPos); - aMIMEInfo->SetPrimaryExtension(goodExt); - return true; - } - } - } - } - return false; -} - bool nsExternalHelperAppService::GetTypeFromExtras(const nsACString& aExtension, nsACString& aMIMEType) { NS_ASSERTION(!aExtension.IsEmpty(), "Empty aExtension parameter!"); // Look for default entry with matching extension. nsDependentCString::const_iterator start, end, iter; int32_t numEntries = ArrayLength(extraMimeEntries); for (int32_t index = 0; index < numEntries; index++) {
--- a/uriloader/exthandler/nsExternalHelperAppService.h +++ b/uriloader/exthandler/nsExternalHelperAppService.h @@ -139,24 +139,16 @@ class nsExternalHelperAppService : publi * Does not change the MIME Type of the MIME Info. * * @see FillMIMEInfoForMimeTypeFromExtras */ nsresult FillMIMEInfoForExtensionFromExtras(const nsACString& aExtension, nsIMIMEInfo* aMIMEInfo); /** - * Replace the primary extension of the mimeinfo object if it's in our - * list of forbidden extensions. This fixes up broken information - * provided to us by the OS. - */ - bool MaybeReplacePrimaryExtension(const nsACString& aPrimaryExtension, - nsIMIMEInfo* aMIMEInfo); - - /** * Searches the "extra" array for a MIME type, and gets its extension. * @param aExtension The extension to search for * @param aMIMEType [out] The found MIME type. * @return true if the extension was found, false otherwise. */ bool GetTypeFromExtras(const nsACString& aExtension, nsACString& aMIMEType); /**