mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1364550 - Get all extensions for a MIME type and not just the preferred one (macOS). r=baku
MozReview-Commit-ID: Ls1vQ6f8tyZ
This commit is contained in:
parent
d1e495344b
commit
baaadbc3f1
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user