summaryrefslogtreecommitdiffstats
path: root/base/file_path.cc
diff options
context:
space:
mode:
authorcevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-15 21:44:31 +0000
committercevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-15 21:44:31 +0000
commit067086103743fa898f4dedae1c7c07a9688c27be (patch)
treed820f706c644698ed3fbe17d3e849dda6a158b0c /base/file_path.cc
parent449f269f07a53ee461aa11e19533fb4c8a32d889 (diff)
downloadchromium_src-067086103743fa898f4dedae1c7c07a9688c27be.zip
chromium_src-067086103743fa898f4dedae1c7c07a9688c27be.tar.gz
chromium_src-067086103743fa898f4dedae1c7c07a9688c27be.tar.bz2
Add "bool FilePath::ReferencesParent()" which adds a clean & simple way for
checking for ".." in a FilePath. Needed to make an upcoming security fix clean. BUG=NONE TEST=FilePathTest.ReferencesParent Review URL: http://codereview.chromium.org/172012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_path.cc')
-rw-r--r--base/file_path.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/base/file_path.cc b/base/file_path.cc
index 6134f2b..222b225 100644
--- a/base/file_path.cc
+++ b/base/file_path.cc
@@ -461,3 +461,17 @@ void FilePath::StripTrailingSeparatorsInternal() {
}
}
}
+
+bool FilePath::ReferencesParent() const {
+ std::vector<FilePath::StringType> components;
+ GetComponents(&components);
+
+ std::vector<FilePath::StringType>::const_iterator it = components.begin();
+ for (; it != components.end(); ++it) {
+ const FilePath::StringType& component = *it;
+ if (component == kParentDirectory)
+ return true;
+ }
+ return false;
+}
+