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

Side by Side Diff: net/cookies/canonical_cookie.cc

Issue 2959123002: Allow paths constructed from URLs rather as well as cookie attributes. (Closed)
Patch Set: Remove test for space in path--GURL escapes those. Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/cookies/canonical_cookie_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Portions of this code based on Mozilla: 5 // Portions of this code based on Mozilla:
6 // (netwerk/cookie/src/nsCookieService.cpp) 6 // (netwerk/cookie/src/nsCookieService.cpp)
7 /* ***** BEGIN LICENSE BLOCK ***** 7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9 * 9 *
10 * The contents of this file are subject to the Mozilla Public License Version 10 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 if (IsSecure() != other.IsSecure()) 397 if (IsSecure() != other.IsSecure())
398 return IsSecure(); 398 return IsSecure();
399 399
400 if (IsHttpOnly() != other.IsHttpOnly()) 400 if (IsHttpOnly() != other.IsHttpOnly())
401 return IsHttpOnly(); 401 return IsHttpOnly();
402 402
403 return Priority() < other.Priority(); 403 return Priority() < other.Priority();
404 } 404 }
405 405
406 bool CanonicalCookie::IsCanonical() const { 406 bool CanonicalCookie::IsCanonical() const {
407 // Not checking domain against ParsedCookie as it may have come purely 407 // Not checking domain or path against ParsedCookie as it may have
408 // from the URL. 408 // come purely from the URL.
409 if (ParsedCookie::ParseTokenString(name_) != name_ || 409 if (ParsedCookie::ParseTokenString(name_) != name_ ||
410 ParsedCookie::ParseValueString(value_) != value_ || 410 ParsedCookie::ParseValueString(value_) != value_ ||
411 ParsedCookie::ParseValueString(path_) != path_ ||
412 !ParsedCookie::IsValidCookieAttributeValue(name_) || 411 !ParsedCookie::IsValidCookieAttributeValue(name_) ||
413 !ParsedCookie::IsValidCookieAttributeValue(value_) || 412 !ParsedCookie::IsValidCookieAttributeValue(value_)) {
414 !ParsedCookie::IsValidCookieAttributeValue(path_)) {
415 return false; 413 return false;
416 } 414 }
417 415
418 if (!last_access_date_.is_null() && creation_date_.is_null()) 416 if (!last_access_date_.is_null() && creation_date_.is_null())
419 return false; 417 return false;
420 418
421 url::CanonHostInfo canon_host_info; 419 url::CanonHostInfo canon_host_info;
422 std::string canonical_domain(CanonicalizeHost(domain_, &canon_host_info)); 420 std::string canonical_domain(CanonicalizeHost(domain_, &canon_host_info));
423 // TODO(rdsmith): This specifically allows for empty domains. The spec 421 // TODO(rdsmith): This specifically allows for empty domains. The spec
424 // suggests this is invalid (if a domain attribute is empty, the cookie's 422 // suggests this is invalid (if a domain attribute is empty, the cookie's
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 return true; 494 return true;
497 } 495 }
498 496
499 std::string CanonicalCookie::DomainWithoutDot() const { 497 std::string CanonicalCookie::DomainWithoutDot() const {
500 if (domain_.empty() || domain_[0] != '.') 498 if (domain_.empty() || domain_[0] != '.')
501 return domain_; 499 return domain_;
502 return domain_.substr(1); 500 return domain_.substr(1);
503 } 501 }
504 502
505 } // namespace net 503 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/cookies/canonical_cookie_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698