Chromium Code Reviews| Index: net/cookies/canonical_cookie.cc |
| diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc |
| index 6c81a55dc7df1d768618d9d76b338a0b0fd79974..949cb9da187651bc1e9bba3ddd1cd9803655c889 100644 |
| --- a/net/cookies/canonical_cookie.cc |
| +++ b/net/cookies/canonical_cookie.cc |
| @@ -50,10 +50,12 @@ |
| #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" |
| #include "url/url_canon.h" |
| +#include "url/url_util.h" |
| using base::Time; |
| using base::TimeDelta; |
| @@ -399,6 +401,29 @@ bool CanonicalCookie::FullCompare(const CanonicalCookie& other) const { |
| return Priority() < other.Priority(); |
| } |
| +bool CanonicalCookie::IsCanonical() const { |
|
mmenke
2017/05/25 19:49:56
Is there a single method I should be comparing thi
Randy Smith (Not in Mondays)
2017/06/07 23:31:40
I modeled it after SetCookieWithDetails minus the
|
| + if (name_.empty()) |
|
mmenke
2017/05/25 19:49:56
Don't we support "Set-Cookie: =foo" and "Set-Cooki
mmenke
2017/05/25 21:25:21
Fun table that indicates we support both of these:
Randy Smith (Not in Mondays)
2017/06/07 23:31:40
Nice catch; my bad. This snuck in a couple of CLs
|
| + return false; |
| + |
| + if (ParsedCookie::ParseTokenString(name_) != name_ || |
| + ParsedCookie::ParseValueString(value_) != value_ || |
| + ParsedCookie::ParseValueString(domain_) != domain_ || |
| + ParsedCookie::ParseValueString(path_) != path_) { |
| + return false; |
| + } |
| + |
| + url::CanonHostInfo ignored; |
| + if (!url::HostIsIPAddress(domain_) && |
| + CanonicalizeHost(domain_, &ignored).empty()) { |
|
mmenke
2017/05/25 19:49:56
What if CanonicalizeHost(domain_) != domain_?
Randy Smith (Not in Mondays)
2017/06/07 23:31:40
Also note that the DCHECK(IsCanonical()) you sugge
Randy Smith (Not in Mondays)
2017/06/07 23:31:40
Oh, tricky. So as noted above I'm copying this lo
|
| + return false; |
| + } |
| + |
| + if (path_[0] != '/') |
| + return false; |
|
mmenke
2017/05/25 19:49:56
Do we always set path to be non-empty, even when n
Randy Smith (Not in Mondays)
2017/06/07 23:31:40
Yes, at least at a couple of places in the stack--
|
| + |
| + return true; |
| +} |
| + |
| // static |
| CanonicalCookie::CookiePrefix CanonicalCookie::GetCookiePrefix( |
| const std::string& name) { |