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