diff options
Diffstat (limited to 'chromium/net/http/http_util_unittest.cc')
-rw-r--r-- | chromium/net/http/http_util_unittest.cc | 130 |
1 files changed, 122 insertions, 8 deletions
diff --git a/chromium/net/http/http_util_unittest.cc b/chromium/net/http/http_util_unittest.cc index bb9bcd92378..ec4e6d108d0 100644 --- a/chromium/net/http/http_util_unittest.cc +++ b/chromium/net/http/http_util_unittest.cc @@ -734,6 +734,18 @@ TEST(HttpUtilTest, ParseContentType) { const bool expected_had_charset; const char* const expected_boundary; } tests[] = { + { "text/html", + "text/html", + "", + false, + "" + }, + { "text/html;", + "text/html", + "", + false, + "" + }, { "text/html; charset=utf-8", "text/html", "utf-8", @@ -763,7 +775,7 @@ TEST(HttpUtilTest, ParseContentType) { "text/html", "", false, - "\"WebKit-ada-df-dsf-adsfadsfs\"" + "WebKit-ada-df-dsf-adsfadsfs" }, // Parameter name is "boundary ", not "boundary". // See https://crbug.com/772834. @@ -778,20 +790,20 @@ TEST(HttpUtilTest, ParseContentType) { "text/html", "", false, - " \"WebKit-ada-df-dsf-adsfadsfs\"" + "WebKit-ada-df-dsf-adsfadsfs" }, // Parameter value includes leading space. See https://crbug.com/772834. { "text/html; boundary= \"WebKit-ada-df-dsf-adsfadsfs\" ", "text/html", "", false, - " \"WebKit-ada-df-dsf-adsfadsfs\"" + "WebKit-ada-df-dsf-adsfadsfs" }, { "text/html; boundary=\"WebKit-ada-df-dsf-adsfadsfs \"", "text/html", "", false, - "\"WebKit-ada-df-dsf-adsfadsfs \"" + "WebKit-ada-df-dsf-adsfadsfs " }, { "text/html; boundary=WebKit-ada-df-dsf-adsfadsfs", "text/html", @@ -799,12 +811,110 @@ TEST(HttpUtilTest, ParseContentType) { false, "WebKit-ada-df-dsf-adsfadsfs" }, + { "text/html; charset", + "text/html", + "", + false, + "" + }, + { "text/html; charset=", + "text/html", + "", + false, + "" + }, + { "text/html; charset= ", + "text/html", + "", + false, + "" + }, + { "text/html; charset= ;", + "text/html", + "", + false, + "" + }, + { "text/html; charset=\"\"", + "text/html", + "", + false, + "" + }, + { "text/html; charset=\" \"", + "text/html", + " ", + true, + "" + }, + { "text/html; charset; charset=; charset=utf-8", + "text/html", + "utf-8", + true, + "" + }, + { "text/html; charset=utf-8; charset=; charset;", + "text/html", + "utf-8", + true, + "" + }, + // Stray quotes ignored. + { "text/html; \"; \"\"; charset=utf-8", + "text/html", + "utf-8", + true, + "" + }, + // Non-leading quotes kept as-is. + { "text/html; charset=u\"tf-8\"", + "text/html", + "u\"tf-8\"", + true, + "" + }, { "text/html; charset=\"utf-8\"", "text/html", "utf-8", true, "" }, + // No closing quote. + { "text/html; charset=\"utf-8", + "text/html", + "utf-8", + true, + "" + }, + // Check that \ is treated as an escape character. + { "text/html; charset=\"\\utf\\-\\8\"", + "text/html", + "utf-8", + true, + "" + }, + // More interseting escape character test - test escaped backslash, escaped + // quote, and backslash at end of input in unterminated quoted string. + { "text/html; charset=\"\\\\\\\"\\", + "text/html", + "\\\"\\", + true, + "" + }, + // Check quoted semicolon. + { "text/html; charset=\";charset=utf-8;\"", + "text/html", + ";charset=utf-8;", + true, + "" + }, + // Unclear if this one should just return utf-8 or not. + { "text/html; charset= \"utf-8\"", + "text/html", + "utf-8", + true, + "" + }, // Regression test for https://crbug.com/772350: // Single quotes are not delimiters but must be treated as part of charset. { "text/html; charset='utf-8'", @@ -823,10 +933,14 @@ TEST(HttpUtilTest, ParseContentType) { std::string boundary; HttpUtil::ParseContentType(tests[i].content_type, &mime_type, &charset, &had_charset, &boundary); - EXPECT_EQ(tests[i].expected_mime_type, mime_type) << "i=" << i; - EXPECT_EQ(tests[i].expected_charset, charset) << "i=" << i; - EXPECT_EQ(tests[i].expected_had_charset, had_charset) << "i=" << i; - EXPECT_EQ(tests[i].expected_boundary, boundary) << "i=" << i; + EXPECT_EQ(tests[i].expected_mime_type, mime_type) + << "content_type=" << tests[i].content_type; + EXPECT_EQ(tests[i].expected_charset, charset) + << "content_type=" << tests[i].content_type; + EXPECT_EQ(tests[i].expected_had_charset, had_charset) + << "content_type=" << tests[i].content_type; + EXPECT_EQ(tests[i].expected_boundary, boundary) + << "content_type=" << tests[i].content_type; } } |