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

Unified Diff: net/cookies/canonical_cookie.cc

Issue 11339032: Account for server vs host clock skew in cookie expiration times. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable test on Android as there's no test server Created 8 years, 2 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 5ae65f67b5868252f351b9c16e07a9a7f4ca9592..306b8fc21729e9f7ba2739f4946b7c49504a7d23 100644
--- a/net/cookies/canonical_cookie.cc
+++ b/net/cookies/canonical_cookie.cc
@@ -139,7 +139,7 @@ CanonicalCookie::CanonicalCookie(const GURL& url, const ParsedCookie& pc)
secure_(pc.IsSecure()),
httponly_(pc.IsHttpOnly()) {
if (pc.HasExpires())
- expiry_date_ = CanonExpiration(pc, creation_date_);
+ expiry_date_ = CanonExpiration(pc, creation_date_, creation_date_);
// Do the best we can with the domain.
std::string cookie_domain;
@@ -181,7 +181,8 @@ std::string CanonicalCookie::CanonPath(const GURL& url,
// static
Time CanonicalCookie::CanonExpiration(const ParsedCookie& pc,
- const Time& current) {
+ const Time& current,
+ const Time& server_time) {
// First, try the Max-Age attribute.
uint64 max_age = 0;
if (pc.HasMaxAge() &&
@@ -195,8 +196,10 @@ Time CanonicalCookie::CanonExpiration(const ParsedCookie& pc,
}
// Try the Expires attribute.
- if (pc.HasExpires())
- return cookie_util::ParseCookieTime(pc.Expires());
+ if (pc.HasExpires()) {
+ // Adjust for clock skew between server and host.
+ return current + (cookie_util::ParseCookieTime(pc.Expires()) - server_time);
+ }
// Invalid or no expiration, persistent cookie.
return Time();
« 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