Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1284)

Unified Diff: base/i18n/file_util_icu.h

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/files/file_path_watcher_linux.cc ('k') | base/i18n/file_util_icu.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/file_util_icu.h
diff --git a/base/i18n/file_util_icu.h b/base/i18n/file_util_icu.h
index 7dd94cd9b06d2ab7ca3751a8b129dcf7237e4885..6d7f2ec6000a52971dafd89410ab7f63338af13a 100644
--- a/base/i18n/file_util_icu.h
+++ b/base/i18n/file_util_icu.h
@@ -18,13 +18,23 @@ namespace i18n {
// param has the same restriction as that for ReplaceIllegalCharacters.
BASE_I18N_EXPORT bool IsFilenameLegal(const string16& file_name);
-// Replaces characters in 'file_name' that are illegal for file names with
-// 'replace_char'. 'file_name' must not be a full or relative path, but just the
+// Replaces characters in |file_name| that are illegal for file names with
+// |replace_char|. |file_name| must not be a full or relative path, but just the
// file name component (since slashes are considered illegal). Any leading or
-// trailing whitespace in 'file_name' is removed.
+// trailing whitespace or periods in |file_name| is also replaced with the
+// |replace_char|.
+//
// Example:
-// file_name == "bad:file*name?.txt", changed to: "bad-file-name-.txt" when
-// 'replace_char' is '-'.
+// "bad:file*name?.txt" will be turned into "bad_file_name_.txt" when
+// |replace_char| is '_'.
+//
+// Warning: Do not use this function as the sole means of sanitizing a filename.
+// While the resulting filename itself would be legal, it doesn't necessarily
+// mean that the file will behave safely. On Windows, certain reserved names
+// refer to devices rather than files (E.g. LPT1), and some filenames could be
+// interpreted as shell namespace extensions (E.g. Foo.{<GUID>}).
+//
+// TODO(asanka): Move full filename sanitization logic here.
BASE_I18N_EXPORT void ReplaceIllegalCharactersInPath(
FilePath::StringType* file_name,
char replace_char);
« no previous file with comments | « base/files/file_path_watcher_linux.cc ('k') | base/i18n/file_util_icu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698