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

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

Issue 2876463006: Allow an arbitrary number of cookie string pairs. (Closed)
Patch Set: Created 3 years, 7 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/parsed_cookie.h ('k') | net/cookies/parsed_cookie_unittest.cc » ('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 // Portions of this code based on Mozilla: 5 // Portions of this code based on Mozilla:
6 // (netwerk/cookie/src/nsCookieService.cpp) 6 // (netwerk/cookie/src/nsCookieService.cpp)
7 /* ***** BEGIN LICENSE BLOCK ***** 7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9 * 9 *
10 * The contents of this file are subject to the Mozilla Public License Version 10 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 std::string::const_iterator end = FindFirstTerminator(cookie_line); 346 std::string::const_iterator end = FindFirstTerminator(cookie_line);
347 347
348 // For an empty |cookie_line|, add an empty-key with an empty value, which 348 // For an empty |cookie_line|, add an empty-key with an empty value, which
349 // has the effect of clearing any prior setting of the empty-key. This is done 349 // has the effect of clearing any prior setting of the empty-key. This is done
350 // to match the behavior of other browsers. See https://crbug.com/601786. 350 // to match the behavior of other browsers. See https://crbug.com/601786.
351 if (it == end) { 351 if (it == end) {
352 pairs_.push_back(TokenValuePair("", "")); 352 pairs_.push_back(TokenValuePair("", ""));
353 return; 353 return;
354 } 354 }
355 355
356 for (int pair_num = 0; pair_num < kMaxPairs && it != end; ++pair_num) { 356 for (int pair_num = 0; it != end; ++pair_num) {
357 TokenValuePair pair; 357 TokenValuePair pair;
358 358
359 std::string::const_iterator token_start, token_end; 359 std::string::const_iterator token_start, token_end;
360 if (!ParseToken(&it, end, &token_start, &token_end)) { 360 if (!ParseToken(&it, end, &token_start, &token_end)) {
361 // Allow first token to be treated as empty-key if unparsable 361 // Allow first token to be treated as empty-key if unparsable
362 if (pair_num != 0) 362 if (pair_num != 0)
363 break; 363 break;
364 364
365 // If parsing failed, start the value parsing at the very beginning. 365 // If parsing failed, start the value parsing at the very beginning.
366 token_start = start; 366 token_start = start;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 --*indexes[i]; 499 --*indexes[i];
500 } 500 }
501 pairs_.erase(pairs_.begin() + index); 501 pairs_.erase(pairs_.begin() + index);
502 } 502 }
503 503
504 bool ParsedCookie::IsSameSiteAttributeValid() const { 504 bool ParsedCookie::IsSameSiteAttributeValid() const {
505 return same_site_index_ == 0 || SameSite() != CookieSameSite::DEFAULT_MODE; 505 return same_site_index_ == 0 || SameSite() != CookieSameSite::DEFAULT_MODE;
506 } 506 }
507 507
508 } // namespace 508 } // namespace
OLDNEW
« no previous file with comments | « net/cookies/parsed_cookie.h ('k') | net/cookies/parsed_cookie_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698