summaryrefslogtreecommitdiffstats
path: root/base/files
diff options
context:
space:
mode:
authordavidben <davidben@chromium.org>2015-11-30 22:46:00 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-01 06:46:49 +0000
commit19011ca7eb79a4a382993031bb549d06dd0fbd27 (patch)
tree2b3d6652b32397f631fa4dc964d98a6ba8196426 /base/files
parent868a3140a14eb47729b07120c3032951a092c7c9 (diff)
downloadchromium_src-19011ca7eb79a4a382993031bb549d06dd0fbd27.zip
chromium_src-19011ca7eb79a4a382993031bb549d06dd0fbd27.tar.gz
chromium_src-19011ca7eb79a4a382993031bb549d06dd0fbd27.tar.bz2
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}
Diffstat (limited to 'base/files')
-rw-r--r--base/files/file_path.cc14
-rw-r--r--base/files/file_path_unittest.cc6
2 files changed, 4 insertions, 16 deletions
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 @@ bool FilePath::ReferencesParent() const {
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 @@ TEST_F(FilePathTest, ReferencesParent) {
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 },