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

Unified Diff: net/cookies/canonical_cookie.cc

Issue 1876683002: Implement SDCH Dictionary domain matching as per RFC 2965 Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Factor out IsDomainMatch from CanonicalCookie and use it in SdchDictionary. Created 4 years, 8 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/base/url_util_unittest.cc ('k') | no next file » | 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 bce2b5477faf484505a964b5769eb721b3fd8de4..95fc188e3d1e658e69ee7e17d91cd0748f552dc2 100644
--- a/net/cookies/canonical_cookie.cc
+++ b/net/cookies/canonical_cookie.cc
@@ -49,6 +49,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "net/base/url_util.h"
#include "net/cookies/cookie_util.h"
#include "net/cookies/parsed_cookie.h"
#include "url/gurl.h"
@@ -345,36 +346,7 @@ bool CanonicalCookie::IsOnPath(const std::string& url_path) const {
}
bool CanonicalCookie::IsDomainMatch(const std::string& host) const {
- // Can domain match in two ways; as a domain cookie (where the cookie
- // domain begins with ".") or as a host cookie (where it doesn't).
-
- // Some consumers of the CookieMonster expect to set cookies on
- // URLs like http://.strange.url. To retrieve cookies in this instance,
- // we allow matching as a host cookie even when the domain_ starts with
- // a period.
- if (host == domain_)
- return true;
-
- // Domain cookie must have an initial ".". To match, it must be
- // equal to url's host with initial period removed, or a suffix of
- // it.
-
- // Arguably this should only apply to "http" or "https" cookies, but
- // extension cookie tests currently use the funtionality, and if we
- // ever decide to implement that it should be done by preventing
- // such cookies from being set.
- if (domain_.empty() || domain_[0] != '.')
- return false;
-
- // The host with a "." prefixed.
- if (domain_.compare(1, std::string::npos, host) == 0)
- return true;
-
- // A pure suffix of the host (ok since we know the domain already
- // starts with a ".")
- return (host.length() > domain_.length() &&
- host.compare(host.length() - domain_.length(),
- domain_.length(), domain_) == 0);
+ return net::IsDomainMatch(domain_, host);
}
bool CanonicalCookie::IncludeForRequestURL(const GURL& url,
« no previous file with comments | « net/base/url_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698