diff options
author | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-02 13:18:42 +0000 |
---|---|---|
committer | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-02 13:18:42 +0000 |
commit | ea0710a82bbd85d450cf8aad9e2d413757bf4832 (patch) | |
tree | c7782d919dd470b06864eef1a4fd46d2e21cfb10 | |
parent | 8df601213f42259a0aae9d2e040f0740b2c17945 (diff) | |
download | chromium_src-ea0710a82bbd85d450cf8aad9e2d413757bf4832.zip chromium_src-ea0710a82bbd85d450cf8aad9e2d413757bf4832.tar.gz chromium_src-ea0710a82bbd85d450cf8aad9e2d413757bf4832.tar.bz2 |
Revert 146616.
Account for server vs host clock skew in cookie expiration times.
When setting a cookie's expiration time in the cookie store we need
to take into account any difference between the HTTP server and the
host machine's real time clock.
BUG=135131
TEST=net_unittests --gtest_filter=CookieMonster/CookieStoreTest/0.TestCookieDeletion
Review URL: https://chromiumcodereview.appspot.com/10692137
R=pauljensen@chromium.org,szym@chromium.org
BUG=152078
Review URL: https://chromiumcodereview.appspot.com/11036007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159685 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/cookies/canonical_cookie.cc | 11 | ||||
-rw-r--r-- | net/cookies/canonical_cookie.h | 3 | ||||
-rw-r--r-- | net/cookies/cookie_monster.cc | 8 | ||||
-rw-r--r-- | net/cookies/cookie_options.h | 13 | ||||
-rw-r--r-- | net/cookies/cookie_store_unittest.h | 27 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.cc | 4 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.h | 1 |
7 files changed, 7 insertions, 60 deletions
diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc index 306b8fc..5ae65f6 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_, creation_date_); + expiry_date_ = CanonExpiration(pc, creation_date_); // Do the best we can with the domain. std::string cookie_domain; @@ -181,8 +181,7 @@ std::string CanonicalCookie::CanonPath(const GURL& url, // static Time CanonicalCookie::CanonExpiration(const ParsedCookie& pc, - const Time& current, - const Time& server_time) { + const Time& current) { // First, try the Max-Age attribute. uint64 max_age = 0; if (pc.HasMaxAge() && @@ -196,10 +195,8 @@ Time CanonicalCookie::CanonExpiration(const ParsedCookie& pc, } // Try the Expires attribute. - if (pc.HasExpires()) { - // Adjust for clock skew between server and host. - return current + (cookie_util::ParseCookieTime(pc.Expires()) - server_time); - } + if (pc.HasExpires()) + return cookie_util::ParseCookieTime(pc.Expires()); // Invalid or no expiration, persistent cookie. return Time(); diff --git a/net/cookies/canonical_cookie.h b/net/cookies/canonical_cookie.h index ba50dfc..1b1ca77 100644 --- a/net/cookies/canonical_cookie.h +++ b/net/cookies/canonical_cookie.h @@ -117,8 +117,7 @@ class NET_EXPORT CanonicalCookie { static std::string GetCookieSourceFromURL(const GURL& url); static std::string CanonPath(const GURL& url, const ParsedCookie& pc); static base::Time CanonExpiration(const ParsedCookie& pc, - const base::Time& current, - const base::Time& server_time); + const base::Time& current); private: // The source member of a canonical cookie is the origin of the URL that tried diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc index eab2e0e..d1f3426 100644 --- a/net/cookies/cookie_monster.cc +++ b/net/cookies/cookie_monster.cc @@ -1703,11 +1703,6 @@ bool CookieMonster::SetCookieWithCreationTimeAndOptions( creation_time = CurrentTime(); last_time_seen_ = creation_time; } - Time server_time; - if (options.has_server_time()) - server_time = options.server_time(); - else - server_time = creation_time; // Parse the cookie. ParsedCookie pc(cookie_line); @@ -1733,8 +1728,7 @@ bool CookieMonster::SetCookieWithCreationTimeAndOptions( pc.MACAlgorithm() : std::string(); scoped_ptr<CanonicalCookie> cc; - Time cookie_expires = - CanonicalCookie::CanonExpiration(pc, creation_time, server_time); + Time cookie_expires = CanonicalCookie::CanonExpiration(pc, creation_time); cc.reset(new CanonicalCookie(url, pc.Name(), pc.Value(), cookie_domain, cookie_path, mac_key, mac_algorithm, diff --git a/net/cookies/cookie_options.h b/net/cookies/cookie_options.h index ed5e2ef..8370702 100644 --- a/net/cookies/cookie_options.h +++ b/net/cookies/cookie_options.h @@ -15,26 +15,15 @@ class CookieOptions { // - reading operations will not return httponly cookies. // - writing operations will not write httponly cookies. CookieOptions() - : exclude_httponly_(true), - server_time_() { + : exclude_httponly_(true) { } void set_exclude_httponly() { exclude_httponly_ = true; } void set_include_httponly() { exclude_httponly_ = false; } bool exclude_httponly() const { return exclude_httponly_; } - // |server_time| indicates what the server sending us the Cookie thought the - // current time was when the cookie was produced. This is used to adjust for - // clock skew between server and host. - void set_server_time(const base::Time& server_time) { - server_time_ = server_time; - } - bool has_server_time() const { return !server_time_.is_null(); } - base::Time server_time() const { return server_time_; } - private: bool exclude_httponly_; - base::Time server_time_; }; } // namespace net diff --git a/net/cookies/cookie_store_unittest.h b/net/cookies/cookie_store_unittest.h index 51c389d..575b0cd 100644 --- a/net/cookies/cookie_store_unittest.h +++ b/net/cookies/cookie_store_unittest.h @@ -147,17 +147,6 @@ class CookieStoreTest : public testing::Test { return callback.result(); } - bool SetCookieWithServerTime(CookieStore* cs, - const GURL& url, - const std::string& cookie_line, - const base::Time& server_time) { - CookieOptions options; - if (!CookieStoreTestTraits::supports_http_only) - options.set_include_httponly(); - options.set_server_time(server_time); - return SetCookieWithOptions(cs, url, cookie_line, options); - } - bool SetCookie(CookieStore* cs, const GURL& url, const std::string& cookie_line) { @@ -713,22 +702,6 @@ TYPED_TEST_P(CookieStoreTest, TestCookieDeletion) { std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-22 22:50:13 GMT")); this->MatchCookieLines("A=B", this->GetCookies(cs, this->url_google_)); - // Check that it is not deleted with significant enough clock skew. - base::Time server_time; - EXPECT_TRUE(base::Time::FromString("Sun, 17-Apr-1977 22:50:13 GMT", - &server_time)); - EXPECT_TRUE(this->SetCookieWithServerTime( - cs, this->url_google_, - std::string(kValidCookieLine) + - "; expires=Mon, 18-Apr-1977 22:50:13 GMT", - server_time)); - this->MatchCookieLines("A=B", this->GetCookies(cs, this->url_google_)); - - // Create a persistent cookie. - EXPECT_TRUE(this->SetCookie(cs, this->url_google_, - std::string(kValidCookieLine) + - "; expires=Mon, 18-Apr-22 22:50:13 GMT")); - this->MatchCookieLines("A=B", this->GetCookies(cs, this->url_google_)); // Delete it via Expires, with a unix epoch of 0. EXPECT_TRUE(this->SetCookie(cs, this->url_google_, std::string(kValidCookieLine) + diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 4bffa9f..6068fa5 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -565,9 +565,6 @@ void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) { FetchResponseCookies(&response_cookies_); - if (!GetResponseHeaders()->GetDateValue(&response_date_)) - response_date_ = base::Time(); - // Now, loop over the response cookies, and attempt to persist each. SaveNextCookie(); } @@ -594,7 +591,6 @@ void URLRequestHttpJob::SaveNextCookie() { response_cookies_.size() > 0) { CookieOptions options; options.set_include_httponly(); - options.set_server_time(response_date_); net::CookieStore::SetCookiesCallback callback( base::Bind(&URLRequestHttpJob::OnCookieSaved, diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h index 3457166..b263046 100644 --- a/net/url_request/url_request_http_job.h +++ b/net/url_request/url_request_http_job.h @@ -98,7 +98,6 @@ class URLRequestHttpJob : public URLRequestJob { std::vector<std::string> response_cookies_; size_t response_cookies_save_index_; - base::Time response_date_; // Auth states for proxy and origin server. AuthState proxy_auth_state_; |