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

Unified Diff: chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc

Issue 491123004: Make sure that HttpRequestHeaders contains valid key-value pairs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: edit comment Created 6 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
diff --git a/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc b/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
index 8853e1e125981d554238682c2ea6f8385f44b414..d2d0b81f07a4162030fb7314d25f31ba51b6b0ba 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
@@ -1603,7 +1603,7 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
for (size_t index = 0; index < arraysize(kUnsafeHeaders); ++index) {
std::string download_url = test_server()->GetURL("slow?0").spec();
- EXPECT_STREQ(errors::kInvalidHeader,
+ EXPECT_STREQ(errors::kInvalidHeaderUnsafe,
RunFunctionAndReturnError(new DownloadsDownloadFunction(),
base::StringPrintf(
"[{\"url\": \"%s\","
@@ -1617,6 +1617,35 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
}
}
+// Tests that invalid header names and values are rejected.
+IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
+ DownloadExtensionTest_Download_InvalidHeaders) {
+ LoadExtension("downloads_split");
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ASSERT_TRUE(test_server()->Start());
+ GoOnTheRecord();
+ std::string download_url = test_server()->GetURL("slow?0").spec();
+ EXPECT_STREQ(errors::kInvalidHeaderName,
+ RunFunctionAndReturnError(new DownloadsDownloadFunction(),
+ base::StringPrintf(
+ "[{\"url\": \"%s\","
+ " \"filename\": \"unsafe-header-crlf.txt\","
+ " \"headers\": [{"
+ " \"name\": \"Header\\r\\nSec-Spoof: Hey\\r\\nX-Split:X\","
+ " \"value\": \"unsafe\"}]}]",
+ download_url.c_str())).c_str());
+
+ EXPECT_STREQ(errors::kInvalidHeaderValue,
+ RunFunctionAndReturnError(new DownloadsDownloadFunction(),
+ base::StringPrintf(
+ "[{\"url\": \"%s\","
+ " \"filename\": \"unsafe-header-crlf.txt\","
+ " \"headers\": [{"
+ " \"name\": \"Invalid-value\","
+ " \"value\": \"hey\\r\\nSec-Spoof: Hey\"}]}]",
+ download_url.c_str())).c_str());
+}
+
#if defined(OS_WIN)
#define MAYBE_DownloadExtensionTest_Download_Subdirectory\
DISABLED_DownloadExtensionTest_Download_Subdirectory
« no previous file with comments | « chrome/browser/extensions/api/downloads/downloads_api.cc ('k') | chrome/browser/extensions/api/web_request/web_request_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698