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

Side by Side Diff: net/cookies/cookie_monster_store_test.cc

Issue 2358343004: When parsing cookie expiration times, clip out of range dates rather
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « net/cookies/canonical_cookie.cc ('k') | net/cookies/cookie_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cookies/cookie_monster_store_test.h" 5 #include "net/cookies/cookie_monster_store_test.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 const base::Time& creation_time) { 130 const base::Time& creation_time) {
131 // Parse the cookie line. 131 // Parse the cookie line.
132 ParsedCookie pc(cookie_line); 132 ParsedCookie pc(cookie_line);
133 EXPECT_TRUE(pc.IsValid()); 133 EXPECT_TRUE(pc.IsValid());
134 134
135 // This helper is simplistic in interpreting a parsed cookie, in order to 135 // This helper is simplistic in interpreting a parsed cookie, in order to
136 // avoid duplicated CookieMonster's CanonPath() and CanonExpiration() 136 // avoid duplicated CookieMonster's CanonPath() and CanonExpiration()
137 // functions. Would be nice to export them, and re-use here. 137 // functions. Would be nice to export them, and re-use here.
138 EXPECT_FALSE(pc.HasMaxAge()); 138 EXPECT_FALSE(pc.HasMaxAge());
139 EXPECT_TRUE(pc.HasPath()); 139 EXPECT_TRUE(pc.HasPath());
140 base::Time cookie_expires = pc.HasExpires() 140 base::Time cookie_expires =
141 ? cookie_util::ParseCookieTime(pc.Expires()) 141 pc.HasExpires() ? cookie_util::ParseCookieExpirationTime(pc.Expires())
142 : base::Time(); 142 : base::Time();
143 std::string cookie_path = pc.Path(); 143 std::string cookie_path = pc.Path();
144 144
145 return CanonicalCookie::Create(url, pc.Name(), pc.Value(), url.host(), 145 return CanonicalCookie::Create(url, pc.Name(), pc.Value(), url.host(),
146 cookie_path, creation_time, cookie_expires, 146 cookie_path, creation_time, cookie_expires,
147 pc.IsSecure(), pc.IsHttpOnly(), pc.SameSite(), 147 pc.IsSecure(), pc.IsHttpOnly(), pc.SameSite(),
148 false, pc.Priority()); 148 false, pc.Priority());
149 } 149 }
150 150
151 void AddCookieToList(const GURL& url, 151 void AddCookieToList(const GURL& url,
152 const std::string& cookie_line, 152 const std::string& cookie_line,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 store->AddCookie(*cc); 260 store->AddCookie(*cc);
261 } 261 }
262 262
263 return base::MakeUnique<CookieMonster>(store.get(), nullptr); 263 return base::MakeUnique<CookieMonster>(store.get(), nullptr);
264 } 264 }
265 265
266 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() { 266 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() {
267 } 267 }
268 268
269 } // namespace net 269 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/canonical_cookie.cc ('k') | net/cookies/cookie_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698