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

Unified Diff: base/files/file_path.cc

Issue 1469153006: Treat '...' as a non-parent path component outside of Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DLOG(WARNING) Created 5 years, 1 month 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 | « no previous file | base/files/file_path_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_path.cc
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index 18775ed9ca99acf7b6b61d21b2e44fbcbdbe0b0b..c142db44b6174c7c5cf2f11d32d90652405c072b 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -562,18 +562,24 @@ bool FilePath::ReferencesParent() const {
std::vector<StringType> components;
GetComponents(&components);
- std::vector<StringType>::const_iterator it = components.begin();
- for (; it != components.end(); ++it) {
- const StringType& component = *it;
+ for (const StringType& component : components) {
+#if defined(OS_WIN)
// 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;
}
« no previous file with comments | « no previous file | base/files/file_path_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698