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

Unified Diff: base/files/file_path_unittest.cc

Issue 1836923002: Handle invalid CFStrings in GetHFSDecomposedForm() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 4 years, 9 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.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_path_unittest.cc
diff --git a/base/files/file_path_unittest.cc b/base/files/file_path_unittest.cc
index f57de67911a2af81689bb382f2f1a59445f695a6..a091e62dd1b4fd7b8c4b2633db41606897d9081b 100644
--- a/base/files/file_path_unittest.cc
+++ b/base/files/file_path_unittest.cc
@@ -1295,4 +1295,23 @@ TEST_F(FilePathTest, PrintTo) {
EXPECT_EQ("foo", ss.str());
}
+// Test GetHFSDecomposedForm should return empty result for invalid UTF-8
+// strings.
+#if defined(OS_MACOSX)
+TEST_F(FilePathTest, GetHFSDecomposedFormWithInvalidInput) {
+ const FilePath::CharType* cases[] = {
+ FPL("\xc3\x28"),
+ FPL("\xe2\x82\x28"),
+ FPL("\xe2\x28\xa1"),
+ FPL("\xf0\x28\x8c\xbc"),
+ FPL("\xf0\x28\x8c\x28"),
+ };
+ for (const auto& invalid_input : cases) {
+ FilePath::StringType observed = FilePath::GetHFSDecomposedForm(
+ invalid_input);
+ EXPECT_TRUE(observed.empty());
+ }
+}
+#endif
+
} // namespace base
« no previous file with comments | « base/files/file_path.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698