From 8960aa956c669654c08c8a0727695ea81d1819e2 Mon Sep 17 00:00:00 2001 From: Yifei Teng Date: Thu, 23 Jul 2015 12:30:07 -0700 Subject: [PATCH] Only allow extensions explicitly specified by the user. Fixes #2296 --- atom/browser/ui/file_dialog_mac.mm | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/atom/browser/ui/file_dialog_mac.mm b/atom/browser/ui/file_dialog_mac.mm index 9cd6c0380be..96d230b1a1e 100644 --- a/atom/browser/ui/file_dialog_mac.mm +++ b/atom/browser/ui/file_dialog_mac.mm @@ -18,25 +18,11 @@ namespace file_dialog { namespace { -CFStringRef CreateUTIFromExtension(const std::string& ext) { - base::ScopedCFTypeRef ext_cf(base::SysUTF8ToCFStringRef(ext)); - return UTTypeCreatePreferredIdentifierForTag( - kUTTagClassFilenameExtension, ext_cf.get(), NULL); -} - void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) { NSMutableSet* file_type_set = [NSMutableSet set]; for (size_t i = 0; i < filters.size(); ++i) { const Filter& filter = filters[i]; for (size_t j = 0; j < filter.second.size(); ++j) { - base::ScopedCFTypeRef uti( - CreateUTIFromExtension(filter.second[j])); - [file_type_set addObject:base::mac::CFToNSCast(uti.get())]; - - // Always allow the extension itself, in case the UTI doesn't map - // back to the original extension correctly. This occurs with dynamic - // UTIs on 10.7 and 10.8. - // See http://crbug.com/148840, http://openradar.me/12316273 base::ScopedCFTypeRef ext_cf( base::SysUTF8ToCFStringRef(filter.second[j])); [file_type_set addObject:base::mac::CFToNSCast(ext_cf.get())];