From 067086103743fa898f4dedae1c7c07a9688c27be Mon Sep 17 00:00:00 2001 From: "cevans@chromium.org" Date: Sat, 15 Aug 2009 21:44:31 +0000 Subject: 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 --- base/file_path.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'base/file_path.cc') 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 components; + GetComponents(&components); + + std::vector::const_iterator it = components.begin(); + for (; it != components.end(); ++it) { + const FilePath::StringType& component = *it; + if (component == kParentDirectory) + return true; + } + return false; +} + -- cgit v1.1