diff options
author | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-05 03:25:28 +0000 |
---|---|---|
committer | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-05 03:25:28 +0000 |
commit | 023fa56d95c8554a931f29772311be45ece0ce7d (patch) | |
tree | 42b2d6ab72f08709af8583d89c84ad1ec2e1e919 /net/base/net_util.h | |
parent | 88c180f52c569642e5be7edfd227689e65b7caa1 (diff) | |
download | chromium_src-023fa56d95c8554a931f29772311be45ece0ce7d.zip chromium_src-023fa56d95c8554a931f29772311be45ece0ce7d.tar.gz chromium_src-023fa56d95c8554a931f29772311be45ece0ce7d.tar.bz2 |
Sanitize directory names from chrome.downloads.onDeterminingFilename.
Also fixes subdirectories in DownloadPathReservationTracker and a bug in downloads_api_unittest.cc where Events were incorrectly matching expectations (false positives).
BUG=181332
Review URL: https://chromiumcodereview.appspot.com/13866027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util.h')
-rw-r--r-- | net/base/net_util.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/net/base/net_util.h b/net/base/net_util.h index 30584a7..5cfd1ea 100644 --- a/net/base/net_util.h +++ b/net/base/net_util.h @@ -287,6 +287,27 @@ NET_EXPORT base::FilePath GenerateFileName( const std::string& mime_type, const std::string& default_name); +// Valid basenames: +// * are not empty +// * are not Windows reserved names (CON, NUL.zip, etc.) +// * are just basenames +// * do not have trailing separators +// * do not equal kCurrentDirectory +// * do not reference the parent directory +// * are valid path components, which: +// - * are not the empty string +// - * do not contain illegal characters +// - * do not end with Windows shell-integrated extensions (even on posix) +// - * do not begin with '.' (which would hide them in most file managers) +// - * do not end with ' ' or '.' +NET_EXPORT bool IsSafePortableBasename(const base::FilePath& path); + +// Basenames of valid relative paths are IsSafePortableBasename(), and internal +// path components of valid relative paths are valid path components as +// described above IsSafePortableBasename(). Valid relative paths are not +// absolute paths. +NET_EXPORT bool IsSafePortableRelativePath(const base::FilePath& path); + // Ensures that the filename and extension is safe to use in the filesystem. // // Assumes that |file_path| already contains a valid path or file name. On |