Merge pull request #2316 from tengyifei/master
Only allow extensions explicitly specified by the user. Fixes #2296
This commit is contained in:
commit
9ec60cd585
1 changed files with 0 additions and 14 deletions
|
@ -18,25 +18,11 @@ namespace file_dialog {
|
||||||
|
|
||||||
namespace {
|
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) {
|
void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
|
||||||
NSMutableSet* file_type_set = [NSMutableSet set];
|
NSMutableSet* file_type_set = [NSMutableSet set];
|
||||||
for (size_t i = 0; i < filters.size(); ++i) {
|
for (size_t i = 0; i < filters.size(); ++i) {
|
||||||
const Filter& filter = filters[i];
|
const Filter& filter = filters[i];
|
||||||
for (size_t j = 0; j < filter.second.size(); ++j) {
|
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::ScopedCFTypeRef<CFStringRef> ext_cf(
|
||||||
base::SysUTF8ToCFStringRef(filter.second[j]));
|
base::SysUTF8ToCFStringRef(filter.second[j]));
|
||||||
[file_type_set addObject:base::mac::CFToNSCast(ext_cf.get())];
|
[file_type_set addObject:base::mac::CFToNSCast(ext_cf.get())];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue