Revert "Treat '...' as a non-parent path component outside of Windows."
This reverts commit f61e0a571a76b94eb5ce059ea25babff6a2bb3a3
(https://codereview.chromium.org/1469153006). It broke some Blink tests as
FilePath::ReferencesParent is also used in things relating to the HTML
FileSystem API.
Ideally, that API should be immune to bizarre Windows-isms and use a different
notion of FilePath from the platform FilePath (which is sensitive to bizarre
Windows-ism and others). But that'll require some work to disentangle. In the
meantime, revert the problematic change so the tests pass.
BUG=464760,563588
TBR=mark@chromium.org,jschuh@chromium.org
Review URL: https://codereview.chromium.org/1488873002
Cr-Commit-Position: refs/heads/master@{#362362}
CrOS-Libchrome-Original-Commit: 19011ca7eb79a4a382993031bb549d06dd0fbd27
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index c142db4..18775ed 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -562,24 +562,18 @@
std::vector<StringType> components;
GetComponents(&components);
- for (const StringType& component : components) {
-#if defined(OS_WIN)
+ std::vector<StringType>::const_iterator it = components.begin();
+ for (; it != components.end(); ++it) {
+ const StringType& component = *it;
// Windows has odd, undocumented behavior with path components containing
// only whitespace and . characters. So, if all we see is . and
// whitespace, then we treat any .. sequence as referencing parent.
+ // For simplicity we enforce this on all platforms.
if (component.find_first_not_of(FILE_PATH_LITERAL(". \n\r\t")) ==
std::string::npos &&
component.find(kParentDirectory) != std::string::npos) {
- // Add a debug-only warning so Windows-specific bot failures are easier to
- // diagnose.
- DLOG_IF(WARNING, component != kParentDirectory)
- << "Rejecting Windows-specific path component.";
return true;
}
-#else
- if (component == kParentDirectory)
- return true;
-#endif
}
return false;
}
diff --git a/base/files/file_path_unittest.cc b/base/files/file_path_unittest.cc
index 4b48a26..bc0e843 100644
--- a/base/files/file_path_unittest.cc
+++ b/base/files/file_path_unittest.cc
@@ -1090,15 +1090,9 @@
const struct UnaryBooleanTestData cases[] = {
{ FPL("."), false },
{ FPL(".."), true },
-#if defined(OS_WIN)
{ FPL(".. "), true },
{ FPL(" .."), true },
{ FPL("..."), true },
-#else
- { FPL(".. "), false },
- { FPL(" .."), false },
- { FPL("..."), false },
-#endif
{ FPL("a.."), false },
{ FPL("..a"), false },
{ FPL("../"), true },