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

Unified Diff: net/http/http_util_unittest.cc

Issue 2101963002: Skip header lines with invalid header name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« net/http/http_util.cc ('K') | « net/http/http_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util_unittest.cc
diff --git a/net/http/http_util_unittest.cc b/net/http/http_util_unittest.cc
index 557d92367a1b28f13bb907e4c481648f102c05b7..c6ef864ddf6be3e64e1b79407eeaad2e99d63969 100644
--- a/net/http/http_util_unittest.cc
+++ b/net/http/http_util_unittest.cc
@@ -178,6 +178,27 @@ TEST(HttpUtilTest, HeadersIterator_MalformedLine) {
EXPECT_FALSE(it.GetNext());
}
+TEST(HttpUtilTest, HeadersIterator_MalformedName) {
+ {
+ std::string headers = "[ignore me] /: 3\r\n";
+
+ HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\r\n");
+
+ EXPECT_FALSE(it.GetNext());
+ }
+ {
+ std::string headers = "[ignore me] /: 3\r\nbar: 4\n";
+
+ HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\r\n");
+
+ ASSERT_TRUE(it.GetNext());
+ EXPECT_EQ(std::string("bar"), it.name());
+ EXPECT_EQ(std::string("4"), it.values());
+
+ EXPECT_FALSE(it.GetNext());
+ }
mmenke 2016/06/28 14:54:01 Could you split this into two tests? Not too conc
robwu 2016/06/28 15:24:42 Done.
+}
+
TEST(HttpUtilTest, HeadersIterator_AdvanceTo) {
std::string headers = "foo: 1\r\n: 2\r\n3\r\nbar: 4";
« net/http/http_util.cc ('K') | « net/http/http_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698