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

Unified Diff: net/cookies/canonical_cookie.cc

Issue 2158863003: Fix CanonicalCookie::IsEquivalentForSecureCookieMatching (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cookies/canonical_cookie.h ('k') | net/cookies/cookie_monster.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/canonical_cookie.cc
diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc
index f8f0ca9d46b6c26066b43b6bdf7156a996ffab5d..d117d5ee3482e60fcccac79431600e1b6f9b83f7 100644
--- a/net/cookies/canonical_cookie.cc
+++ b/net/cookies/canonical_cookie.cc
@@ -137,8 +137,7 @@ CanonicalCookie::CanonicalCookie(const GURL& url,
bool httponly,
CookieSameSite same_site,
CookiePriority priority)
- : source_(url.SchemeIsFile() ? url : url.GetOrigin()),
- name_(name),
+ : name_(name),
value_(value),
domain_(domain),
path_(path),
@@ -328,6 +327,12 @@ std::unique_ptr<CanonicalCookie> CanonicalCookie::Create(
secure, http_only, same_site, priority));
}
+bool CanonicalCookie::IsEquivalentForSecureCookieMatching(
+ const CanonicalCookie& ecc) const {
+ return (name_ == ecc.Name() && (ecc.IsDomainMatch(DomainWithoutDot()) ||
+ IsDomainMatch(ecc.DomainWithoutDot())));
+}
+
bool CanonicalCookie::IsOnPath(const std::string& url_path) const {
// A zero length would be unsafe for our trailing '/' checks, and
@@ -518,4 +523,10 @@ bool CanonicalCookie::IsCookiePrefixValid(CanonicalCookie::CookiePrefix prefix,
return true;
}
+std::string CanonicalCookie::DomainWithoutDot() const {
+ if (domain_.empty() || domain_[0] != '.')
+ return domain_;
+ return domain_.substr(1);
+}
+
} // namespace net
« no previous file with comments | « net/cookies/canonical_cookie.h ('k') | net/cookies/cookie_monster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698