| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "net/cookies/cookie_constants.h" | 7 #include "net/cookies/cookie_constants.h" |
| 8 #include "net/cookies/parsed_cookie.h" | 8 #include "net/cookies/parsed_cookie.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 TEST(ParsedCookieTest, TestBasic) { | 13 TEST(ParsedCookieTest, TestBasic) { |
| 14 ParsedCookie pc("a=b"); | 14 ParsedCookie pc("a=b"); |
| 15 EXPECT_TRUE(pc.IsValid()); | 15 EXPECT_TRUE(pc.IsValid()); |
| 16 EXPECT_FALSE(pc.IsSecure()); | 16 EXPECT_FALSE(pc.IsSecure()); |
| 17 EXPECT_EQ("a", pc.Name()); | 17 EXPECT_EQ("a", pc.Name()); |
| 18 EXPECT_EQ("b", pc.Value()); | 18 EXPECT_EQ("b", pc.Value()); |
| 19 } | 19 } |
| 20 | 20 |
| 21 TEST(ParsedCookieTest, TestQuoted) { | 21 TEST(ParsedCookieTest, TestQuoted) { |
| 22 // These are some quoting cases which the major browsers all | 22 // These are some quoting cases which the major browsers all |
| 23 // handle differently. I've tested Internet Explorer 6, Opera 9.6, | 23 // handle differently. I've tested Internet Explorer 6, Opera 9.6, |
| 24 // Firefox 3, and Safari Windows 3.2.1. We originally tried to match | 24 // Firefox 3, and Safari Windows 3.2.1. We originally tried to match |
| 25 // Firefox closely, however we now match Internet Explorer and Safari. | 25 // Firefox closely, however we now match Internet Explorer and Safari. |
| 26 const char* values[] = { | 26 const char* values[] = { |
| 27 // Trailing whitespace after a quoted value. The whitespace after | 27 // Trailing whitespace after a quoted value. The whitespace after |
| 28 // the quote is stripped in all browsers. | 28 // the quote is stripped in all browsers. |
| 29 "\"zzz \" ", "\"zzz \"", | 29 "\"zzz \" ", "\"zzz \"", |
| 30 // Handling a quoted value with a ';', like FOO="zz;pp" ; | 30 // Handling a quoted value with a ';', like FOO="zz;pp" ; |
| 31 // IE and Safari: "zz; | 31 // IE and Safari: "zz; |
| 32 // Firefox and Opera: "zz;pp" | 32 // Firefox and Opera: "zz;pp" |
| 33 "\"zz;pp\" ;", "\"zz", | 33 "\"zz;pp\" ;", "\"zz", |
| 34 // Handling a value with multiple quoted parts, like FOO="zzz " "ppp" ; | 34 // Handling a value with multiple quoted parts, like FOO="zzz " "ppp" ; |
| 35 // IE and Safari: "zzz " "ppp"; | 35 // IE and Safari: "zzz " "ppp"; |
| 36 // Firefox: "zzz "; | 36 // Firefox: "zzz "; |
| 37 // Opera: <rejects cookie> | 37 // Opera: <rejects cookie> |
| 38 "\"zzz \" \"ppp\" ", "\"zzz \" \"ppp\"", | 38 "\"zzz \" \"ppp\" ", "\"zzz \" \"ppp\"", |
| 39 // A quote in a value that didn't start quoted. like FOO=A"B ; | 39 // A quote in a value that didn't start quoted. like FOO=A"B ; |
| 40 // IE, Safari, and Firefox: A"B; | 40 // IE, Safari, and Firefox: A"B; |
| 41 // Opera: <rejects cookie> | 41 // Opera: <rejects cookie> |
| 42 "A\"B", "A\"B", | 42 "A\"B", "A\"B", |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 for (size_t i = 0; i < arraysize(values); i += 2) { | 45 for (size_t i = 0; i < arraysize(values); i += 2) { |
| 46 std::string input(values[i]); | 46 std::string input(values[i]); |
| 47 std::string expected(values[i + 1]); | 47 std::string expected(values[i + 1]); |
| 48 | 48 |
| 49 ParsedCookie pc("aBc=" + input + " ; path=\"/\" ; httponly "); | 49 ParsedCookie pc("aBc=" + input + " ; path=\"/\" ; httponly "); |
| 50 EXPECT_TRUE(pc.IsValid()); | 50 EXPECT_TRUE(pc.IsValid()); |
| 51 EXPECT_FALSE(pc.IsSecure()); | 51 EXPECT_FALSE(pc.IsSecure()); |
| 52 EXPECT_TRUE(pc.IsHttpOnly()); | 52 EXPECT_TRUE(pc.IsHttpOnly()); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 EXPECT_EQ("== BC", pc.Value()); | 147 EXPECT_EQ("== BC", pc.Value()); |
| 148 EXPECT_FALSE(pc.HasPath()); | 148 EXPECT_FALSE(pc.HasPath()); |
| 149 EXPECT_FALSE(pc.HasDomain()); | 149 EXPECT_FALSE(pc.HasDomain()); |
| 150 EXPECT_TRUE(pc.IsSecure()); | 150 EXPECT_TRUE(pc.IsSecure()); |
| 151 EXPECT_TRUE(pc.IsHttpOnly()); | 151 EXPECT_TRUE(pc.IsHttpOnly()); |
| 152 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); | 152 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); |
| 153 EXPECT_EQ(4U, pc.NumberOfAttributes()); | 153 EXPECT_EQ(4U, pc.NumberOfAttributes()); |
| 154 } | 154 } |
| 155 | 155 |
| 156 TEST(ParsedCookieTest, QuotedTrailingWhitespace) { | 156 TEST(ParsedCookieTest, QuotedTrailingWhitespace) { |
| 157 ParsedCookie pc("ANCUUID=\"zohNumRKgI0oxyhSsV3Z7D\" ; " | 157 ParsedCookie pc( |
| 158 "expires=Sun, 18-Apr-2027 21:06:29 GMT ; " | 158 "ANCUUID=\"zohNumRKgI0oxyhSsV3Z7D\" ; " |
| 159 "path=/ ; "); | 159 "expires=Sun, 18-Apr-2027 21:06:29 GMT ; " |
| 160 "path=/ ; "); |
| 160 EXPECT_TRUE(pc.IsValid()); | 161 EXPECT_TRUE(pc.IsValid()); |
| 161 EXPECT_EQ("ANCUUID", pc.Name()); | 162 EXPECT_EQ("ANCUUID", pc.Name()); |
| 162 // Stripping whitespace after the quotes matches all other major browsers. | 163 // Stripping whitespace after the quotes matches all other major browsers. |
| 163 EXPECT_EQ("\"zohNumRKgI0oxyhSsV3Z7D\"", pc.Value()); | 164 EXPECT_EQ("\"zohNumRKgI0oxyhSsV3Z7D\"", pc.Value()); |
| 164 EXPECT_TRUE(pc.HasExpires()); | 165 EXPECT_TRUE(pc.HasExpires()); |
| 165 EXPECT_TRUE(pc.HasPath()); | 166 EXPECT_TRUE(pc.HasPath()); |
| 166 EXPECT_EQ("/", pc.Path()); | 167 EXPECT_EQ("/", pc.Path()); |
| 167 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); | 168 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); |
| 168 EXPECT_EQ(2U, pc.NumberOfAttributes()); | 169 EXPECT_EQ(2U, pc.NumberOfAttributes()); |
| 169 } | 170 } |
| 170 | 171 |
| 171 TEST(ParsedCookieTest, TrailingWhitespace) { | 172 TEST(ParsedCookieTest, TrailingWhitespace) { |
| 172 ParsedCookie pc("ANCUUID=zohNumRKgI0oxyhSsV3Z7D ; " | 173 ParsedCookie pc( |
| 173 "expires=Sun, 18-Apr-2027 21:06:29 GMT ; " | 174 "ANCUUID=zohNumRKgI0oxyhSsV3Z7D ; " |
| 174 "path=/ ; "); | 175 "expires=Sun, 18-Apr-2027 21:06:29 GMT ; " |
| 176 "path=/ ; "); |
| 175 EXPECT_TRUE(pc.IsValid()); | 177 EXPECT_TRUE(pc.IsValid()); |
| 176 EXPECT_EQ("ANCUUID", pc.Name()); | 178 EXPECT_EQ("ANCUUID", pc.Name()); |
| 177 EXPECT_EQ("zohNumRKgI0oxyhSsV3Z7D", pc.Value()); | 179 EXPECT_EQ("zohNumRKgI0oxyhSsV3Z7D", pc.Value()); |
| 178 EXPECT_TRUE(pc.HasExpires()); | 180 EXPECT_TRUE(pc.HasExpires()); |
| 179 EXPECT_TRUE(pc.HasPath()); | 181 EXPECT_TRUE(pc.HasPath()); |
| 180 EXPECT_EQ("/", pc.Path()); | 182 EXPECT_EQ("/", pc.Path()); |
| 181 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); | 183 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); |
| 182 EXPECT_EQ(2U, pc.NumberOfAttributes()); | 184 EXPECT_EQ(2U, pc.NumberOfAttributes()); |
| 183 } | 185 } |
| 184 | 186 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 EXPECT_EQ("BB", pc1.Value()); | 228 EXPECT_EQ("BB", pc1.Value()); |
| 227 EXPECT_TRUE(pc2.IsValid()); | 229 EXPECT_TRUE(pc2.IsValid()); |
| 228 EXPECT_EQ("AAA", pc2.Name()); | 230 EXPECT_EQ("AAA", pc2.Name()); |
| 229 EXPECT_EQ("BB", pc2.Value()); | 231 EXPECT_EQ("BB", pc2.Value()); |
| 230 EXPECT_TRUE(pc3.IsValid()); | 232 EXPECT_TRUE(pc3.IsValid()); |
| 231 EXPECT_EQ("AAA", pc3.Name()); | 233 EXPECT_EQ("AAA", pc3.Name()); |
| 232 EXPECT_EQ("BB", pc3.Value()); | 234 EXPECT_EQ("BB", pc3.Value()); |
| 233 } | 235 } |
| 234 | 236 |
| 235 TEST(ParsedCookieTest, ParseTokensAndValues) { | 237 TEST(ParsedCookieTest, ParseTokensAndValues) { |
| 236 EXPECT_EQ("hello", | 238 EXPECT_EQ("hello", ParsedCookie::ParseTokenString("hello\nworld")); |
| 237 ParsedCookie::ParseTokenString("hello\nworld")); | 239 EXPECT_EQ("fs!!@", ParsedCookie::ParseTokenString("fs!!@;helloworld")); |
| 238 EXPECT_EQ("fs!!@", | |
| 239 ParsedCookie::ParseTokenString("fs!!@;helloworld")); | |
| 240 EXPECT_EQ("hello world\tgood", | 240 EXPECT_EQ("hello world\tgood", |
| 241 ParsedCookie::ParseTokenString("hello world\tgood\rbye")); | 241 ParsedCookie::ParseTokenString("hello world\tgood\rbye")); |
| 242 EXPECT_EQ("A", | 242 EXPECT_EQ("A", ParsedCookie::ParseTokenString("A=B=C;D=E")); |
| 243 ParsedCookie::ParseTokenString("A=B=C;D=E")); | 243 EXPECT_EQ("hello", ParsedCookie::ParseValueString("hello\nworld")); |
| 244 EXPECT_EQ("hello", | 244 EXPECT_EQ("fs!!@", ParsedCookie::ParseValueString("fs!!@;helloworld")); |
| 245 ParsedCookie::ParseValueString("hello\nworld")); | |
| 246 EXPECT_EQ("fs!!@", | |
| 247 ParsedCookie::ParseValueString("fs!!@;helloworld")); | |
| 248 EXPECT_EQ("hello world\tgood", | 245 EXPECT_EQ("hello world\tgood", |
| 249 ParsedCookie::ParseValueString("hello world\tgood\rbye")); | 246 ParsedCookie::ParseValueString("hello world\tgood\rbye")); |
| 250 EXPECT_EQ("A=B=C", | 247 EXPECT_EQ("A=B=C", ParsedCookie::ParseValueString("A=B=C;D=E")); |
| 251 ParsedCookie::ParseValueString("A=B=C;D=E")); | |
| 252 } | 248 } |
| 253 | 249 |
| 254 TEST(ParsedCookieTest, SerializeCookieLine) { | 250 TEST(ParsedCookieTest, SerializeCookieLine) { |
| 255 const char input[] = "ANCUUID=zohNumRKgI0oxyhSsV3Z7D ; " | 251 const char input[] = |
| 256 "expires=Sun, 18-Apr-2027 21:06:29 GMT ; " | 252 "ANCUUID=zohNumRKgI0oxyhSsV3Z7D ; " |
| 257 "path=/ ; priority=low ; "; | 253 "expires=Sun, 18-Apr-2027 21:06:29 GMT ; " |
| 258 const char output[] = "ANCUUID=zohNumRKgI0oxyhSsV3Z7D; " | 254 "path=/ ; priority=low ; "; |
| 259 "expires=Sun, 18-Apr-2027 21:06:29 GMT; " | 255 const char output[] = |
| 260 "path=/; priority=low"; | 256 "ANCUUID=zohNumRKgI0oxyhSsV3Z7D; " |
| 257 "expires=Sun, 18-Apr-2027 21:06:29 GMT; " |
| 258 "path=/; priority=low"; |
| 261 ParsedCookie pc(input); | 259 ParsedCookie pc(input); |
| 262 EXPECT_EQ(output, pc.ToCookieLine()); | 260 EXPECT_EQ(output, pc.ToCookieLine()); |
| 263 } | 261 } |
| 264 | 262 |
| 265 | |
| 266 TEST(ParsedCookieTest, SetNameAndValue) { | 263 TEST(ParsedCookieTest, SetNameAndValue) { |
| 267 ParsedCookie empty((std::string())); | 264 ParsedCookie empty((std::string())); |
| 268 EXPECT_FALSE(empty.IsValid()); | 265 EXPECT_FALSE(empty.IsValid()); |
| 269 EXPECT_FALSE(empty.SetDomain("foobar.com")); | 266 EXPECT_FALSE(empty.SetDomain("foobar.com")); |
| 270 EXPECT_TRUE(empty.SetName("name")); | 267 EXPECT_TRUE(empty.SetName("name")); |
| 271 EXPECT_TRUE(empty.SetValue("value")); | 268 EXPECT_TRUE(empty.SetValue("value")); |
| 272 EXPECT_EQ("name=value", empty.ToCookieLine()); | 269 EXPECT_EQ("name=value", empty.ToCookieLine()); |
| 273 EXPECT_TRUE(empty.IsValid()); | 270 EXPECT_TRUE(empty.IsValid()); |
| 274 | 271 |
| 275 // We don't test | 272 // We don't test |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 328 |
| 332 // Set all other attributes and check that they are appended in order. | 329 // Set all other attributes and check that they are appended in order. |
| 333 EXPECT_TRUE(pc.SetDomain("domain.com")); | 330 EXPECT_TRUE(pc.SetDomain("domain.com")); |
| 334 EXPECT_TRUE(pc.SetPath("/")); | 331 EXPECT_TRUE(pc.SetPath("/")); |
| 335 EXPECT_TRUE(pc.SetExpires("Sun, 18-Apr-2027 21:06:29 GMT")); | 332 EXPECT_TRUE(pc.SetExpires("Sun, 18-Apr-2027 21:06:29 GMT")); |
| 336 EXPECT_TRUE(pc.SetMaxAge("12345")); | 333 EXPECT_TRUE(pc.SetMaxAge("12345")); |
| 337 EXPECT_TRUE(pc.SetIsSecure(true)); | 334 EXPECT_TRUE(pc.SetIsSecure(true)); |
| 338 EXPECT_TRUE(pc.SetIsHttpOnly(true)); | 335 EXPECT_TRUE(pc.SetIsHttpOnly(true)); |
| 339 EXPECT_TRUE(pc.SetIsHttpOnly(true)); | 336 EXPECT_TRUE(pc.SetIsHttpOnly(true)); |
| 340 EXPECT_TRUE(pc.SetPriority("HIGH")); | 337 EXPECT_TRUE(pc.SetPriority("HIGH")); |
| 341 EXPECT_EQ("name=value; domain=domain.com; path=/; " | 338 EXPECT_EQ( |
| 342 "expires=Sun, 18-Apr-2027 21:06:29 GMT; max-age=12345; secure; " | 339 "name=value; domain=domain.com; path=/; " |
| 343 "httponly; priority=HIGH", | 340 "expires=Sun, 18-Apr-2027 21:06:29 GMT; max-age=12345; secure; " |
| 344 pc.ToCookieLine()); | 341 "httponly; priority=HIGH", |
| 342 pc.ToCookieLine()); |
| 345 EXPECT_TRUE(pc.HasDomain()); | 343 EXPECT_TRUE(pc.HasDomain()); |
| 346 EXPECT_TRUE(pc.HasPath()); | 344 EXPECT_TRUE(pc.HasPath()); |
| 347 EXPECT_TRUE(pc.HasExpires()); | 345 EXPECT_TRUE(pc.HasExpires()); |
| 348 EXPECT_TRUE(pc.HasMaxAge()); | 346 EXPECT_TRUE(pc.HasMaxAge()); |
| 349 EXPECT_TRUE(pc.IsSecure()); | 347 EXPECT_TRUE(pc.IsSecure()); |
| 350 EXPECT_TRUE(pc.IsHttpOnly()); | 348 EXPECT_TRUE(pc.IsHttpOnly()); |
| 351 EXPECT_EQ(COOKIE_PRIORITY_HIGH, pc.Priority()); | 349 EXPECT_EQ(COOKIE_PRIORITY_HIGH, pc.Priority()); |
| 352 | 350 |
| 353 // Clear one attribute from the middle. | 351 // Clear one attribute from the middle. |
| 354 EXPECT_TRUE(pc.SetPath("/foo")); | 352 EXPECT_TRUE(pc.SetPath("/foo")); |
| 355 EXPECT_TRUE(pc.HasDomain()); | 353 EXPECT_TRUE(pc.HasDomain()); |
| 356 EXPECT_TRUE(pc.HasPath()); | 354 EXPECT_TRUE(pc.HasPath()); |
| 357 EXPECT_TRUE(pc.HasExpires()); | 355 EXPECT_TRUE(pc.HasExpires()); |
| 358 EXPECT_TRUE(pc.IsSecure()); | 356 EXPECT_TRUE(pc.IsSecure()); |
| 359 EXPECT_TRUE(pc.IsHttpOnly()); | 357 EXPECT_TRUE(pc.IsHttpOnly()); |
| 360 EXPECT_EQ("name=value; domain=domain.com; path=/foo; " | 358 EXPECT_EQ( |
| 361 "expires=Sun, 18-Apr-2027 21:06:29 GMT; max-age=12345; secure; " | 359 "name=value; domain=domain.com; path=/foo; " |
| 362 "httponly; priority=HIGH", | 360 "expires=Sun, 18-Apr-2027 21:06:29 GMT; max-age=12345; secure; " |
| 363 pc.ToCookieLine()); | 361 "httponly; priority=HIGH", |
| 362 pc.ToCookieLine()); |
| 364 | 363 |
| 365 // Set priority to medium. | 364 // Set priority to medium. |
| 366 EXPECT_TRUE(pc.SetPriority("medium")); | 365 EXPECT_TRUE(pc.SetPriority("medium")); |
| 367 EXPECT_EQ("name=value; domain=domain.com; path=/foo; " | 366 EXPECT_EQ( |
| 368 "expires=Sun, 18-Apr-2027 21:06:29 GMT; max-age=12345; secure; " | 367 "name=value; domain=domain.com; path=/foo; " |
| 369 "httponly; priority=medium", | 368 "expires=Sun, 18-Apr-2027 21:06:29 GMT; max-age=12345; secure; " |
| 370 pc.ToCookieLine()); | 369 "httponly; priority=medium", |
| 370 pc.ToCookieLine()); |
| 371 | 371 |
| 372 // Clear the rest and change the name and value. | 372 // Clear the rest and change the name and value. |
| 373 EXPECT_TRUE(pc.SetDomain(std::string())); | 373 EXPECT_TRUE(pc.SetDomain(std::string())); |
| 374 EXPECT_TRUE(pc.SetPath(std::string())); | 374 EXPECT_TRUE(pc.SetPath(std::string())); |
| 375 EXPECT_TRUE(pc.SetExpires(std::string())); | 375 EXPECT_TRUE(pc.SetExpires(std::string())); |
| 376 EXPECT_TRUE(pc.SetMaxAge(std::string())); | 376 EXPECT_TRUE(pc.SetMaxAge(std::string())); |
| 377 EXPECT_TRUE(pc.SetIsSecure(false)); | 377 EXPECT_TRUE(pc.SetIsSecure(false)); |
| 378 EXPECT_TRUE(pc.SetIsHttpOnly(false)); | 378 EXPECT_TRUE(pc.SetIsHttpOnly(false)); |
| 379 EXPECT_TRUE(pc.SetName("name2")); | 379 EXPECT_TRUE(pc.SetName("name2")); |
| 380 EXPECT_TRUE(pc.SetValue("value2")); | 380 EXPECT_TRUE(pc.SetValue("value2")); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 EXPECT_EQ("name=value; priority=lowerest", pc.ToCookieLine()); | 417 EXPECT_EQ("name=value; priority=lowerest", pc.ToCookieLine()); |
| 418 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); | 418 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); |
| 419 | 419 |
| 420 EXPECT_TRUE(pc.SetPriority("")); | 420 EXPECT_TRUE(pc.SetPriority("")); |
| 421 EXPECT_EQ("name=value", pc.ToCookieLine()); | 421 EXPECT_EQ("name=value", pc.ToCookieLine()); |
| 422 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); | 422 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); |
| 423 } | 423 } |
| 424 | 424 |
| 425 TEST(ParsedCookieTest, InvalidNonAlphanumericChars) { | 425 TEST(ParsedCookieTest, InvalidNonAlphanumericChars) { |
| 426 ParsedCookie pc1("name=\x05"); | 426 ParsedCookie pc1("name=\x05"); |
| 427 ParsedCookie pc2("name=foo" "\x1c" "bar"); | 427 ParsedCookie pc2( |
| 428 ParsedCookie pc3("name=foobar" "\x11"); | 428 "name=foo" |
| 429 ParsedCookie pc4("name=\x02" "foobar"); | 429 "\x1c" |
| 430 "bar"); |
| 431 ParsedCookie pc3( |
| 432 "name=foobar" |
| 433 "\x11"); |
| 434 ParsedCookie pc4( |
| 435 "name=\x02" |
| 436 "foobar"); |
| 430 | 437 |
| 431 ParsedCookie pc5("\x05=value"); | 438 ParsedCookie pc5("\x05=value"); |
| 432 ParsedCookie pc6("foo" "\x05" "bar=value"); | 439 ParsedCookie pc6( |
| 433 ParsedCookie pc7("foobar" "\x05" "=value"); | 440 "foo" |
| 434 ParsedCookie pc8("\x05" "foobar" "=value"); | 441 "\x05" |
| 442 "bar=value"); |
| 443 ParsedCookie pc7( |
| 444 "foobar" |
| 445 "\x05" |
| 446 "=value"); |
| 447 ParsedCookie pc8( |
| 448 "\x05" |
| 449 "foobar" |
| 450 "=value"); |
| 435 | 451 |
| 436 ParsedCookie pc9("foo" "\x05" "bar" "=foo" "\x05" "bar"); | 452 ParsedCookie pc9( |
| 453 "foo" |
| 454 "\x05" |
| 455 "bar" |
| 456 "=foo" |
| 457 "\x05" |
| 458 "bar"); |
| 437 | 459 |
| 438 ParsedCookie pc10("foo=bar;ba" "\x05" "z=boo"); | 460 ParsedCookie pc10( |
| 439 ParsedCookie pc11("foo=bar;baz=bo" "\x05" "o"); | 461 "foo=bar;ba" |
| 440 ParsedCookie pc12("foo=bar;ba" "\05" "z=bo" "\x05" "o"); | 462 "\x05" |
| 463 "z=boo"); |
| 464 ParsedCookie pc11( |
| 465 "foo=bar;baz=bo" |
| 466 "\x05" |
| 467 "o"); |
| 468 ParsedCookie pc12( |
| 469 "foo=bar;ba" |
| 470 "\05" |
| 471 "z=bo" |
| 472 "\x05" |
| 473 "o"); |
| 441 | 474 |
| 442 EXPECT_FALSE(pc1.IsValid()); | 475 EXPECT_FALSE(pc1.IsValid()); |
| 443 EXPECT_FALSE(pc2.IsValid()); | 476 EXPECT_FALSE(pc2.IsValid()); |
| 444 EXPECT_FALSE(pc3.IsValid()); | 477 EXPECT_FALSE(pc3.IsValid()); |
| 445 EXPECT_FALSE(pc4.IsValid()); | 478 EXPECT_FALSE(pc4.IsValid()); |
| 446 EXPECT_FALSE(pc5.IsValid()); | 479 EXPECT_FALSE(pc5.IsValid()); |
| 447 EXPECT_FALSE(pc6.IsValid()); | 480 EXPECT_FALSE(pc6.IsValid()); |
| 448 EXPECT_FALSE(pc7.IsValid()); | 481 EXPECT_FALSE(pc7.IsValid()); |
| 449 EXPECT_FALSE(pc8.IsValid()); | 482 EXPECT_FALSE(pc8.IsValid()); |
| 450 EXPECT_FALSE(pc9.IsValid()); | 483 EXPECT_FALSE(pc9.IsValid()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 EXPECT_EQ(pc4_literal, pc4.ToCookieLine()); | 516 EXPECT_EQ(pc4_literal, pc4.ToCookieLine()); |
| 484 EXPECT_TRUE(pc5.IsValid()); | 517 EXPECT_TRUE(pc5.IsValid()); |
| 485 EXPECT_EQ(pc5_literal, pc5.ToCookieLine()); | 518 EXPECT_EQ(pc5_literal, pc5.ToCookieLine()); |
| 486 EXPECT_TRUE(pc6.IsValid()); | 519 EXPECT_TRUE(pc6.IsValid()); |
| 487 EXPECT_EQ(pc6_literal, pc6.ToCookieLine()); | 520 EXPECT_EQ(pc6_literal, pc6.ToCookieLine()); |
| 488 EXPECT_TRUE(pc7.IsValid()); | 521 EXPECT_TRUE(pc7.IsValid()); |
| 489 EXPECT_EQ(pc7_literal, pc7.ToCookieLine()); | 522 EXPECT_EQ(pc7_literal, pc7.ToCookieLine()); |
| 490 EXPECT_TRUE(pc8.IsValid()); | 523 EXPECT_TRUE(pc8.IsValid()); |
| 491 EXPECT_EQ(pc8_literal, pc8.ToCookieLine()); | 524 EXPECT_EQ(pc8_literal, pc8.ToCookieLine()); |
| 492 } | 525 } |
| 493 | |
| 494 } | 526 } |
| OLD | NEW |