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

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

Issue 2438513003: When parsing cookie expiration times, saturate out of range dates (Closed)
Patch Set: Response to comments 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 int64_t* seconds_till_expiry) { 108 int64_t* seconds_till_expiry) {
109 // 'Max-Age' is processed first because according to: 109 // 'Max-Age' is processed first because according to:
110 // http://tools.ietf.org/html/rfc6265#section-5.3 'Max-Age' attribute 110 // http://tools.ietf.org/html/rfc6265#section-5.3 'Max-Age' attribute
111 // overrides 'Expires' attribute. 111 // overrides 'Expires' attribute.
112 if (cookie->HasMaxAge() && 112 if (cookie->HasMaxAge() &&
113 base::StringToInt64(cookie->MaxAge(), seconds_till_expiry)) { 113 base::StringToInt64(cookie->MaxAge(), seconds_till_expiry)) {
114 return true; 114 return true;
115 } 115 }
116 116
117 Time parsed_expiry_time; 117 Time parsed_expiry_time;
118 if (cookie->HasExpires()) 118 if (cookie->HasExpires()) {
119 parsed_expiry_time = net::cookie_util::ParseCookieTime(cookie->Expires()); 119 parsed_expiry_time =
120 net::cookie_util::ParseCookieExpirationTime(cookie->Expires());
121 }
120 122
121 if (!parsed_expiry_time.is_null()) { 123 if (!parsed_expiry_time.is_null()) {
122 *seconds_till_expiry = 124 *seconds_till_expiry =
123 ceil((parsed_expiry_time - Time::Now()).InSecondsF()); 125 ceil((parsed_expiry_time - Time::Now()).InSecondsF());
124 return *seconds_till_expiry >= 0; 126 return *seconds_till_expiry >= 0;
125 } 127 }
126 return false; 128 return false;
127 } 129 }
128 130
129 bool NullableEquals(const int* a, const int* b) { 131 bool NullableEquals(const int* a, const int* b) {
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 for (size_t i = 0; i < kResourceTypeStringsLength; ++i) { 1317 for (size_t i = 0; i < kResourceTypeStringsLength; ++i) {
1316 if (type_str == kResourceTypeStrings[i]) { 1318 if (type_str == kResourceTypeStrings[i]) {
1317 found = true; 1319 found = true;
1318 types->push_back(kResourceTypeValues[i]); 1320 types->push_back(kResourceTypeValues[i]);
1319 } 1321 }
1320 } 1322 }
1321 return found; 1323 return found;
1322 } 1324 }
1323 1325
1324 } // namespace extension_web_request_api_helpers 1326 } // 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