]> khamidou — GitHub mirrors - electron.git/commitdiff
Only allow extensions explicitly specified by the user. Fixes #2296
authorYifei Teng <yifei@skycatch.com>
Thu, 23 Jul 2015 19:30:07 +0000 (12:30 -0700)
committerYifei Teng <yifei@skycatch.com>
Thu, 23 Jul 2015 19:30:07 +0000 (12:30 -0700)
atom/browser/ui/file_dialog_mac.mm

index 9cd6c0380be6c4ce8634f40cb718b0696b1216c3..96d230b1a1ea18110a6d5ac22a249cb9c19d2dbf 100644 (file)
@@ -18,25 +18,11 @@ namespace file_dialog {
 
 namespace {
 
-CFStringRef CreateUTIFromExtension(const std::string& ext) {
-  base::ScopedCFTypeRef<CFStringRef> 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<CFStringRef> 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<CFStringRef> ext_cf(
           base::SysUTF8ToCFStringRef(filter.second[j]));
       [file_type_set addObject:base::mac::CFToNSCast(ext_cf.get())];