summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/fileapi/file_system_browsertest.cc5
-rw-r--r--webkit/fileapi/file_system_util.cc26
-rw-r--r--webkit/fileapi/file_system_util.h11
-rw-r--r--webkit/fileapi/file_system_util_unittest.cc8
4 files changed, 20 insertions, 30 deletions
diff --git a/content/browser/fileapi/file_system_browsertest.cc b/content/browser/fileapi/file_system_browsertest.cc
index 7a226af..56dd4ec 100644
--- a/content/browser/fileapi/file_system_browsertest.cc
+++ b/content/browser/fileapi/file_system_browsertest.cc
@@ -230,10 +230,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemLayoutTest, OpRemove) {
RunLayoutTest("op-remove.html");
}
-// TODO(kinuko): This has been broken before but the bug has surfaced
-// due to a partial fix for drive-letter handling.
-// http://crbug.com/176253
-IN_PROC_BROWSER_TEST_F(FileSystemLayoutTest, DISABLED_OpRestrictedChars) {
+IN_PROC_BROWSER_TEST_F(FileSystemLayoutTest, OpRestrictedChars) {
RunLayoutTest("op-restricted-chars.html");
}
diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc
index 79e2b76..24513d8 100644
--- a/webkit/fileapi/file_system_util.cc
+++ b/webkit/fileapi/file_system_util.cc
@@ -49,10 +49,7 @@ base::FilePath VirtualPath::BaseName(const base::FilePath& virtual_path) {
}
void VirtualPath::GetComponents(
- const base::FilePath& path,
- std::vector<base::FilePath::StringType>* components) {
- typedef base::FilePath::StringType StringType;
-
+ const base::FilePath& path, std::vector<base::FilePath::StringType>* components) {
DCHECK(components);
if (!components)
return;
@@ -60,15 +57,20 @@ void VirtualPath::GetComponents(
if (path.value().empty())
return;
- StringType::size_type begin = 0, end = 0;
- while (begin < path.value().length() && end != StringType::npos) {
- end = path.value().find_first_of(base::FilePath::kSeparators, begin);
- StringType component = path.value().substr(
- begin, end == StringType::npos ? StringType::npos : end - begin);
- if (!component.empty() && component != base::FilePath::kCurrentDirectory)
- components->push_back(component);
- begin = end + 1;
+ std::vector<base::FilePath::StringType> ret_val;
+ base::FilePath current = path;
+ base::FilePath base;
+
+ // Due to the way things are implemented, base::FilePath::DirName works here,
+ // whereas base::FilePath::BaseName doesn't.
+ while (current != current.DirName()) {
+ base = BaseName(current);
+ ret_val.push_back(base.value());
+ current = current.DirName();
}
+
+ *components =
+ std::vector<base::FilePath::StringType>(ret_val.rbegin(), ret_val.rend());
}
FilePath::StringType VirtualPath::GetNormalizedFilePath(const FilePath& path) {
diff --git a/webkit/fileapi/file_system_util.h b/webkit/fileapi/file_system_util.h
index 351f094..ffefe57 100644
--- a/webkit/fileapi/file_system_util.h
+++ b/webkit/fileapi/file_system_util.h
@@ -36,12 +36,11 @@ class WEBKIT_STORAGE_EXPORT VirtualPath {
// character.
static base::FilePath BaseName(const base::FilePath& virtual_path);
- // Likewise, use this instead of base::FilePath::GetComponents when
- // operating on virtual paths.
- // Note that this assumes very clean input, with no leading slash, and
- // it will not evaluate '..' components.
- static void GetComponents(
- const base::FilePath& path,
+ // Likewise, use this instead of base::FilePath::GetComponents when operating on
+ // virtual paths.
+ // Note that this assumes very clean input, with no leading slash, and it will
+ // not evaluate '.' or '..' components.
+ static void GetComponents(const base::FilePath& path,
std::vector<base::FilePath::StringType>* components);
// Returns a path name ensuring that it begins with kRoot and all path
diff --git a/webkit/fileapi/file_system_util_unittest.cc b/webkit/fileapi/file_system_util_unittest.cc
index 6ffe873..3bf54fb 100644
--- a/webkit/fileapi/file_system_util_unittest.cc
+++ b/webkit/fileapi/file_system_util_unittest.cc
@@ -106,14 +106,6 @@ TEST_F(FileSystemUtilTest, VirtualPathGetComponents) {
{ FILE_PATH_LITERAL("/foo/bar"),
2,
{ FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } },
- { FILE_PATH_LITERAL("c:/bar"),
- 2,
- { FILE_PATH_LITERAL("c:"), FILE_PATH_LITERAL("bar") } },
-#ifdef FILE_PATH_USES_WIN_SEPARATORS
- { FILE_PATH_LITERAL("c:\\bar"),
- 2,
- { FILE_PATH_LITERAL("c:"), FILE_PATH_LITERAL("bar") } },
-#endif
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
base::FilePath input = base::FilePath(test_cases[i].path);