| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/base/filename_util_unsafe.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/strings/string_util.h" | |
| 9 #include "net/base/filename_util_internal.h" | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 // Local ICU-independent implementation of filename sanitizing functions defined | |
| 14 // in base/i18n/file_util_icu.h. Does not require ICU because on POSIX systems | |
| 15 // all international characters are considered legal, so only control and | |
| 16 // special characters have to be replaced. | |
| 17 const base::FilePath::CharType illegal_characters[] = | |
| 18 FILE_PATH_LITERAL("\"*/:<>?\\\\|\001\002\003\004\005\006\007\010\011\012") | |
| 19 FILE_PATH_LITERAL("\013\014\015\016\017\020\021\022\023\024\025\025\027"); | |
| 20 | |
| 21 void ReplaceIllegalCharactersInPath(base::FilePath::StringType* file_name, | |
| 22 char replace_char) { | |
| 23 base::ReplaceChars(*file_name, | |
| 24 illegal_characters, | |
| 25 base::FilePath::StringType(1, replace_char), | |
| 26 file_name); | |
| 27 } | |
| 28 | |
| 29 } // namespace | |
| 30 | |
| 31 namespace net { | |
| 32 | |
| 33 base::FilePath::StringType GenerateFileExtensionUnsafe( | |
| 34 const GURL& url, | |
| 35 const std::string& content_disposition, | |
| 36 const std::string& referrer_charset, | |
| 37 const std::string& suggested_name, | |
| 38 const std::string& mime_type, | |
| 39 const std::string& default_file_name) { | |
| 40 base::FilePath filepath = | |
| 41 GenerateFileNameImpl(url, | |
| 42 content_disposition, | |
| 43 referrer_charset, | |
| 44 suggested_name, | |
| 45 mime_type, | |
| 46 default_file_name, | |
| 47 base::Bind(&ReplaceIllegalCharactersInPath)); | |
| 48 return filepath.Extension(); | |
| 49 } | |
| 50 | |
| 51 } // namespace net | |
| OLD | NEW |