From baaadbc3f1db7ebf4188f73ba02cd894862e00c0 Mon Sep 17 00:00:00 2001 From: Jessica Jong Date: Thu, 18 May 2017 02:37:00 +0800 Subject: [PATCH] Bug 1364550 - Get all extensions for a MIME type and not just the preferred one (macOS). r=baku MozReview-Commit-ID: Ls1vQ6f8tyZ --- uriloader/exthandler/mac/nsOSHelperAppService.mm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/uriloader/exthandler/mac/nsOSHelperAppService.mm b/uriloader/exthandler/mac/nsOSHelperAppService.mm index 00f12f5448ba..4794a8fcb008 100644 --- a/uriloader/exthandler/mac/nsOSHelperAppService.mm +++ b/uriloader/exthandler/mac/nsOSHelperAppService.mm @@ -497,15 +497,17 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType, nsAutoCString mimeType; mimeInfoMac->GetMIMEType(mimeType); if (*aFound && !mimeType.IsEmpty()) { - // If we have a MIME type, make sure its preferred extension is included - // in our list. + // If we have a MIME type, make sure its extension list is included in our + // list. NSURLFileTypeMappings *map = [NSURLFileTypeMappings sharedMappings]; NSString *typeStr = [NSString stringWithCString:mimeType.get() encoding:NSASCIIStringEncoding]; - NSString *extStr = map ? [map preferredExtensionForMIMEType:typeStr] : NULL; - if (extStr) { - nsAutoCString preferredExt; - preferredExt.Assign((char *)[extStr cStringUsingEncoding:NSASCIIStringEncoding]); - mimeInfoMac->AppendExtension(preferredExt); + NSArray *extensionsList = map ? [map extensionsForMIMEType:typeStr] : NULL; + if (extensionsList) { + for (NSString* extension in extensionsList) { + nsAutoCString ext; + ext.Assign((char *)[extension cStringUsingEncoding:NSASCIIStringEncoding]); + mimeInfoMac->AppendExtension(ext); + } } CFStringRef cfType = ::CFStringCreateWithCString(NULL, mimeType.get(), kCFStringEncodingUTF8);