Disallow slashes in filename in downloads.download()

Review URL: http://codereview.chromium.org/10103004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134588 0039d316-1c4b-4281-b951-d872f2087c98
parent 0a3d10c5
...@@ -172,12 +172,11 @@ DownloadItem::DownloadState StateEnumFromString(const std::string& state) { ...@@ -172,12 +172,11 @@ DownloadItem::DownloadState StateEnumFromString(const std::string& state) {
bool ValidateFilename(const string16& filename) { bool ValidateFilename(const string16& filename) {
// TODO(benjhayden): More robust validation of filename. // TODO(benjhayden): More robust validation of filename.
if (filename.size() >= 2u && filename[0] == L'.' && filename[1] == L'.') if ((filename.find('/') != string16::npos) ||
(filename.find('\\') != string16::npos))
return false; return false;
if (filename.size() >= 2u && filename[0] == L'.' && filename[1] == L'.')
if (filename.size() >= 1u && filename[0] == L'/')
return false; return false;
return true; return true;
} }
......
...@@ -588,6 +588,14 @@ chrome.test.getConfig(function(testConfig) { ...@@ -588,6 +588,14 @@ chrome.test.getConfig(function(testConfig) {
})); }));
}, },
// TODO(benjhayden): Update this test when downloading to sub-directories is
// supported.
function downloadFilenameDisallowSlashes() {
downloads.download(
{'url': SAFE_FAST_URL, 'filename': 'subdirectory/file.txt'},
chrome.test.callbackFail(downloads.ERROR_GENERIC));
},
function downloadOnCreated() { function downloadOnCreated() {
// Test that the onCreated event fires when we start a download. // Test that the onCreated event fires when we start a download.
var downloadId = getNextId(); var downloadId = getNextId();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment