diff options
Diffstat (limited to 'net/spdy')
-rw-r--r-- | net/spdy/spdy_alt_svc_wire_format.cc | 8 | ||||
-rw-r--r-- | net/spdy/spdy_alt_svc_wire_format_test.cc | 14 | ||||
-rw-r--r-- | net/spdy/spdy_framer_test.cc | 16 |
3 files changed, 21 insertions, 17 deletions
diff --git a/net/spdy/spdy_alt_svc_wire_format.cc b/net/spdy/spdy_alt_svc_wire_format.cc index fba2dc5..cc68e87 100644 --- a/net/spdy/spdy_alt_svc_wire_format.cc +++ b/net/spdy/spdy_alt_svc_wire_format.cc @@ -147,7 +147,11 @@ bool SpdyAltSvcWireFormat::ParseHeaderFieldValue( return false; } } else if (parameter_name.compare("p") == 0) { - if (!ParseProbability(parameter_value_begin, c, &probability)) { + // Probability value is enclosed in quotation marks. + if (*parameter_value_begin != '"' || *(c - 1) != '"') { + return false; + } + if (!ParseProbability(parameter_value_begin + 1, c - 1, &probability)) { return false; } } @@ -220,7 +224,7 @@ std::string SpdyAltSvcWireFormat::SerializeHeaderFieldValue( base::StringAppendF(&value, "; ma=%d", altsvc.max_age); } if (altsvc.probability != 1.0) { - base::StringAppendF(&value, "; p=%.2f", altsvc.probability); + base::StringAppendF(&value, "; p=\"%.2f\"", altsvc.probability); } } return value; diff --git a/net/spdy/spdy_alt_svc_wire_format_test.cc b/net/spdy/spdy_alt_svc_wire_format_test.cc index 76567e4..6933e7c 100644 --- a/net/spdy/spdy_alt_svc_wire_format_test.cc +++ b/net/spdy/spdy_alt_svc_wire_format_test.cc @@ -88,12 +88,12 @@ void FuzzHeaderFieldValue( } if (i & 1 << 5) { expected_altsvc->probability = 0.33; - header_field_value->append("; P=.33"); + header_field_value->append("; P=\".33\""); } if (i & 1 << 6) { expected_altsvc->probability = 0.0; expected_altsvc->version = 24; - header_field_value->append("; p=0;v=24"); + header_field_value->append("; p=\"0\";v=24"); } if (i & 1 << 7) { expected_altsvc->max_age = 999999999; @@ -101,7 +101,7 @@ void FuzzHeaderFieldValue( } if (i & 1 << 8) { expected_altsvc->probability = 0.0; - header_field_value->append("; P=0."); + header_field_value->append("; P=\"0.\""); } if (i & 1 << 9) { header_field_value->append(";"); @@ -141,7 +141,7 @@ void FuzzAlternativeService(int i, } if (i & 1 << 3) { altsvc->probability = 0.33; - expected_header_field_value->append("; p=0.33"); + expected_header_field_value->append("; p=\"0.33\""); } } @@ -268,9 +268,9 @@ TEST(SpdyAltSvcWireFormatTest, ParseHeaderFieldValueInvalid) { "a=", "a=\"", "a=\"b\"", "a=\":\"", "a=\"c:\"", "a=\"c:foo\"", "a=\"c:42foo\"", "a=\"b:42\"bar", "a=\"b:42\" ; m", "a=\"b:42\" ; min-age", "a=\"b:42\" ; ma", "a=\"b:42\" ; ma=", - "a=\"b:42\" ; ma=ma", "a=\"b:42\" ; ma=123bar", "a=\"b:42\" ; p=-2", - "a=\"b:42\" ; p=..", "a=\"b:42\" ; p=1.05", - "a=\"b:42\" ; v=-3", "a=\"b:42\" ; v=1.2"}; + "a=\"b:42\" ; ma=ma", "a=\"b:42\" ; ma=123bar", "a=\"b:42\" ; p=\"-2\"", + "a=\"b:42\" ; p=\"..\"", "a=\"b:42\" ; p=\"1.05\"", "a=\"b:42\" ; p=0.4", + "a=\"b:42\" ; p=\" 1.0\"", "a=\"b:42\" ; v=-3", "a=\"b:42\" ; v=1.2"}; for (const char* invalid_field_value : invalid_field_value_array) { EXPECT_FALSE(SpdyAltSvcWireFormat::ParseHeaderFieldValue( invalid_field_value, &altsvc_vector)) diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc index e593862..e7e719b 100644 --- a/net/spdy/spdy_framer_test.cc +++ b/net/spdy/spdy_framer_test.cc @@ -3532,14 +3532,14 @@ TEST_P(SpdyFramerTest, CreateAltSvc) { const char kType = static_cast<unsigned char>( SpdyConstants::SerializeFrameType(spdy_version_, ALTSVC)); const unsigned char kFrameData[] = { - 0x00, 0x00, 0x4f, kType, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x06, - 'o', 'r', 'i', 'g', 'i', 'n', 'p', 'i', 'd', '1', '=', - '"', 'h', 'o', 's', 't', ':', '4', '4', '3', '"', ';', - ' ', 'm', 'a', '=', '5', ',', 'p', '%', '2', '2', '%', - '3', 'D', 'i', '%', '3', 'A', 'd', '=', '"', 'h', '_', - '\\', '\\', 'o', '\\', '"', 's', 't', ':', '1', '2', '3', - '"', ';', ' ', 'v', '=', '2', '4', ';', ' ', 'm', 'a', - '=', '4', '2', ';', ' ', 'p', '=', '0', '.', '2', '0'}; + 0x00, 0x00, 0x51, kType, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x06, 'o', + 'r', 'i', 'g', 'i', 'n', 'p', 'i', 'd', '1', '=', '"', 'h', + 'o', 's', 't', ':', '4', '4', '3', '"', ';', ' ', 'm', 'a', + '=', '5', ',', 'p', '%', '2', '2', '%', '3', 'D', 'i', '%', + '3', 'A', 'd', '=', '"', 'h', '_', '\\', '\\', 'o', '\\', '"', + 's', 't', ':', '1', '2', '3', '"', ';', ' ', 'v', '=', '2', + '4', ';', ' ', 'm', 'a', '=', '4', '2', ';', ' ', 'p', '=', + '"', '0', '.', '2', '0', '"'}; SpdyAltSvcIR altsvc_ir(3); altsvc_ir.set_origin("origin"); altsvc_ir.add_altsvc( |