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

Side by Side Diff: base/files/file_path.cc

Issue 1488873002: Revert "Treat '...' as a non-parent path component outside of Windows." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/files/file_path_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 FilePath new_path(path_); 555 FilePath new_path(path_);
556 new_path.StripTrailingSeparatorsInternal(); 556 new_path.StripTrailingSeparatorsInternal();
557 557
558 return new_path; 558 return new_path;
559 } 559 }
560 560
561 bool FilePath::ReferencesParent() const { 561 bool FilePath::ReferencesParent() const {
562 std::vector<StringType> components; 562 std::vector<StringType> components;
563 GetComponents(&components); 563 GetComponents(&components);
564 564
565 for (const StringType& component : components) { 565 std::vector<StringType>::const_iterator it = components.begin();
566 #if defined(OS_WIN) 566 for (; it != components.end(); ++it) {
567 const StringType& component = *it;
567 // Windows has odd, undocumented behavior with path components containing 568 // Windows has odd, undocumented behavior with path components containing
568 // only whitespace and . characters. So, if all we see is . and 569 // only whitespace and . characters. So, if all we see is . and
569 // whitespace, then we treat any .. sequence as referencing parent. 570 // whitespace, then we treat any .. sequence as referencing parent.
571 // For simplicity we enforce this on all platforms.
570 if (component.find_first_not_of(FILE_PATH_LITERAL(". \n\r\t")) == 572 if (component.find_first_not_of(FILE_PATH_LITERAL(". \n\r\t")) ==
571 std::string::npos && 573 std::string::npos &&
572 component.find(kParentDirectory) != std::string::npos) { 574 component.find(kParentDirectory) != std::string::npos) {
573 // Add a debug-only warning so Windows-specific bot failures are easier to
574 // diagnose.
575 DLOG_IF(WARNING, component != kParentDirectory)
576 << "Rejecting Windows-specific path component.";
577 return true; 575 return true;
578 } 576 }
579 #else
580 if (component == kParentDirectory)
581 return true;
582 #endif
583 } 577 }
584 return false; 578 return false;
585 } 579 }
586 580
587 #if defined(OS_POSIX) 581 #if defined(OS_POSIX)
588 // See file_path.h for a discussion of the encoding of paths on POSIX 582 // See file_path.h for a discussion of the encoding of paths on POSIX
589 // platforms. These encoding conversion functions are not quite correct. 583 // platforms. These encoding conversion functions are not quite correct.
590 584
591 string16 FilePath::LossyDisplayName() const { 585 string16 FilePath::LossyDisplayName() const {
592 return WideToUTF16(SysNativeMBToWide(path_)); 586 return WideToUTF16(SysNativeMBToWide(path_));
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 #endif 1312 #endif
1319 } 1313 }
1320 1314
1321 #if defined(OS_ANDROID) 1315 #if defined(OS_ANDROID)
1322 bool FilePath::IsContentUri() const { 1316 bool FilePath::IsContentUri() const {
1323 return StartsWith(path_, "content://", base::CompareCase::INSENSITIVE_ASCII); 1317 return StartsWith(path_, "content://", base::CompareCase::INSENSITIVE_ASCII);
1324 } 1318 }
1325 #endif 1319 #endif
1326 1320
1327 } // namespace base 1321 } // namespace base
OLDNEW
« 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