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

Unified Diff: third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp

Issue 2889033002: Better header value parsing for Server-Timing. (Closed)
Patch Set: add TODOs for skipping all whitespace Created 3 years, 7 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: third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
diff --git a/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp b/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
index 8be3e53cec47f1c1b7f0d98589cb331c14938f09..cb420d55c428e6cfee3a08cae9378ae8fdc86ef6 100644
--- a/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
+++ b/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp
@@ -500,18 +500,6 @@ TEST(HTTPParsersTest, ParseMultipartHeadersContentCharset) {
EXPECT_EQ("utf-8", response.TextEncodingName());
}
-TEST(HTTPParsersTest, CheckDoubleQuotedString) {
- EXPECT_EQ(CheckDoubleQuotedString(""), "");
- EXPECT_EQ(CheckDoubleQuotedString("\""), "\"");
- EXPECT_EQ(CheckDoubleQuotedString("\"\""), "");
- EXPECT_EQ(CheckDoubleQuotedString("foo"), "foo");
- EXPECT_EQ(CheckDoubleQuotedString("\"foo"), "\"foo");
- EXPECT_EQ(CheckDoubleQuotedString("foo\""), "foo\"");
- EXPECT_EQ(CheckDoubleQuotedString("\"foo\""), "foo");
- EXPECT_EQ(CheckDoubleQuotedString("\"foo\"bar\""), "foo\"bar");
- EXPECT_EQ(CheckDoubleQuotedString("\"foo\\bar\""), "foobar");
-}
-
void testServerTimingHeader(const char* headerValue,
Vector<Vector<String>> expectedResults) {
std::unique_ptr<ServerTimingHeaderVector> results =
@@ -997,6 +985,36 @@ TEST(HTTPParsersTest, ParseServerTimingHeader) {
{{"metric1", "12.3", "description1"},
{"metric2", "45.6", "description2"},
{"metric3", "78.9", "description3"}});
+
+ // header value: metric;"description"
+ // expected description: description
+ testServerTimingHeader("metric;\"description\"",
+ {{"metric", "0", "description"}});
+
+ // header value: metric;"1\"2"
+ // expected description: 1"2
+ std::string headerValue = "metric;";
+ headerValue.push_back('"');
+ headerValue.push_back('1');
+ headerValue.push_back('\\');
+ headerValue.push_back('"');
+ headerValue.push_back('2');
+ headerValue.push_back('"');
Yoav Weiss 2017/05/18 21:45:05 Why are you pushing back the chars here? Did strin
+ std::string expectedDescription = "";
+ expectedDescription.push_back('1');
+ expectedDescription.push_back('"');
+ expectedDescription.push_back('2');
+ testServerTimingHeader(
+ headerValue.c_str(),
+ {{"metric", "0", String(expectedDescription.c_str())}});
+
+ // header value: metric;"1\=\;\,2"
+ // expected description: 1=;,2
+ testServerTimingHeader("metric;\"1\\=\\;\\,2\"", {{"metric", "0", "1=;,2"}});
+
+ // header value: metric;"1=;,2"
+ // expected description: 1=;,2
+ testServerTimingHeader("metric;\"1=;,2\"", {{"metric", "0", "1=;,2"}});
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698