Revert 200603 "Make Windows traversal checking handle pathologic..."
Seems to have broken base_unittests on Linux ASAN.
> Make Windows traversal checking handle pathological cases
>
> Different versions of Windows have undocumented quirks in handling path components
> (e.g. truncating or ignoring certain leading or trailing characters). In order to avoid potential
> security bugs we're going to treat components more loosely and risk a few unlikely false
> positives from FilePath::ReferencesParent().
>
> BUG=181617
> R=brettw@chromium.org, ericu@chromium.org
>
> Review URL: https://codereview.chromium.org/12771015
TBR=jschuh@chromium.org
Review URL: https://codereview.chromium.org/15095015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200610 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 08c627d0b9f2854baf1e2b37229b7101b2b21a53
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index 03ccbcd..e9495a1 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -553,15 +553,8 @@
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) {
+ if (component == kParentDirectory)
return true;
- }
}
return false;
}
diff --git a/base/files/file_path_unittest.cc b/base/files/file_path_unittest.cc
index 4dc1e7f..dbc9244 100644
--- a/base/files/file_path_unittest.cc
+++ b/base/files/file_path_unittest.cc
@@ -401,9 +401,6 @@
{ FPL("//a"), true },
{ FPL("c:a/b"), false },
{ FPL("?:/a"), false },
- { FPL("/.. "), false },
- { FPL("/ .."), false },
- { FPL("/..."), false },
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
{ FPL("/"), false },
{ FPL("/a"), false },
@@ -431,9 +428,6 @@
{ FPL("//a"), true },
{ FPL("c:a\\b"), false },
{ FPL("?:\\a"), false },
- { FPL("\\.. "), false },
- { FPL("\\ .."), false },
- { FPL("\\..."), false },
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
{ FPL("\\"), false },
{ FPL("\\a"), false },