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

Side by Side Diff: extensions/browser/api/web_request/web_request_api_helpers.cc

Issue 2358343004: When parsing cookie expiration times, clip out of range dates rather
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/cookies/canonical_cookie.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 "extensions/browser/api/web_request/web_request_api_helpers.h" 5 #include "extensions/browser/api/web_request/web_request_api_helpers.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 int64_t* seconds_till_expiry) { 105 int64_t* seconds_till_expiry) {
106 // 'Max-Age' is processed first because according to: 106 // 'Max-Age' is processed first because according to:
107 // http://tools.ietf.org/html/rfc6265#section-5.3 'Max-Age' attribute 107 // http://tools.ietf.org/html/rfc6265#section-5.3 'Max-Age' attribute
108 // overrides 'Expires' attribute. 108 // overrides 'Expires' attribute.
109 if (cookie->HasMaxAge() && 109 if (cookie->HasMaxAge() &&
110 base::StringToInt64(cookie->MaxAge(), seconds_till_expiry)) { 110 base::StringToInt64(cookie->MaxAge(), seconds_till_expiry)) {
111 return true; 111 return true;
112 } 112 }
113 113
114 Time parsed_expiry_time; 114 Time parsed_expiry_time;
115 if (cookie->HasExpires()) 115 if (cookie->HasExpires()) {
116 parsed_expiry_time = net::cookie_util::ParseCookieTime(cookie->Expires()); 116 parsed_expiry_time =
117 net::cookie_util::ParseCookieExpirationTime(cookie->Expires());
118 }
117 119
118 if (!parsed_expiry_time.is_null()) { 120 if (!parsed_expiry_time.is_null()) {
119 *seconds_till_expiry = 121 *seconds_till_expiry =
120 ceil((parsed_expiry_time - Time::Now()).InSecondsF()); 122 ceil((parsed_expiry_time - Time::Now()).InSecondsF());
121 return *seconds_till_expiry >= 0; 123 return *seconds_till_expiry >= 0;
122 } 124 }
123 return false; 125 return false;
124 } 126 }
125 127
126 bool NullableEquals(const int* a, const int* b) { 128 bool NullableEquals(const int* a, const int* b) {
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 for (size_t i = 0; i < kResourceTypeStringsLength; ++i) { 1314 for (size_t i = 0; i < kResourceTypeStringsLength; ++i) {
1313 if (type_str == kResourceTypeStrings[i]) { 1315 if (type_str == kResourceTypeStrings[i]) {
1314 found = true; 1316 found = true;
1315 types->push_back(kResourceTypeValues[i]); 1317 types->push_back(kResourceTypeValues[i]);
1316 } 1318 }
1317 } 1319 }
1318 return found; 1320 return found;
1319 } 1321 }
1320 1322
1321 } // namespace extension_web_request_api_helpers 1323 } // namespace extension_web_request_api_helpers
OLDNEW
« no previous file with comments | « no previous file | net/cookies/canonical_cookie.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698