OLD | NEW |
---|---|
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 27 matching lines...) Expand all Loading... | |
38 * decision by deleting the provisions above and replace them with the notice | 38 * decision by deleting the provisions above and replace them with the notice |
39 * and other provisions required by the GPL or the LGPL. If you do not delete | 39 * and other provisions required by the GPL or the LGPL. If you do not delete |
40 * the provisions above, a recipient may use your version of this file under | 40 * the provisions above, a recipient may use your version of this file under |
41 * the terms of any one of the MPL, the GPL or the LGPL. | 41 * the terms of any one of the MPL, the GPL or the LGPL. |
42 * | 42 * |
43 * ***** END LICENSE BLOCK ***** */ | 43 * ***** END LICENSE BLOCK ***** */ |
44 | 44 |
45 #include "net/cookies/parsed_cookie.h" | 45 #include "net/cookies/parsed_cookie.h" |
46 | 46 |
47 #include "base/logging.h" | 47 #include "base/logging.h" |
48 #include "base/metrics/histogram.h" | |
Ilya Sherman
2016/08/25 20:04:49
nit: histogram_macros
Adam Rice
2016/08/26 01:36:29
Fixed, thanks.
| |
48 #include "base/strings/string_util.h" | 49 #include "base/strings/string_util.h" |
49 | 50 |
50 namespace { | 51 namespace { |
51 | 52 |
52 const char kPathTokenName[] = "path"; | 53 const char kPathTokenName[] = "path"; |
53 const char kDomainTokenName[] = "domain"; | 54 const char kDomainTokenName[] = "domain"; |
54 const char kExpiresTokenName[] = "expires"; | 55 const char kExpiresTokenName[] = "expires"; |
55 const char kMaxAgeTokenName[] = "max-age"; | 56 const char kMaxAgeTokenName[] = "max-age"; |
56 const char kSecureTokenName[] = "secure"; | 57 const char kSecureTokenName[] = "secure"; |
57 const char kHttpOnlyTokenName[] = "httponly"; | 58 const char kHttpOnlyTokenName[] = "httponly"; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 if (pair_num != 0) | 419 if (pair_num != 0) |
419 pair.first = base::ToLowerASCII(pair.first); | 420 pair.first = base::ToLowerASCII(pair.first); |
420 // Ignore Set-Cookie directives contaning control characters. See | 421 // Ignore Set-Cookie directives contaning control characters. See |
421 // http://crbug.com/238041. | 422 // http://crbug.com/238041. |
422 if (!IsValidCookieAttributeValue(pair.first) || | 423 if (!IsValidCookieAttributeValue(pair.first) || |
423 !IsValidCookieAttributeValue(pair.second)) { | 424 !IsValidCookieAttributeValue(pair.second)) { |
424 pairs_.clear(); | 425 pairs_.clear(); |
425 break; | 426 break; |
426 } | 427 } |
427 | 428 |
429 if (pair_num == 0) { | |
430 UMA_HISTOGRAM_BOOLEAN("Cookie.CookieLineCookieValueValidity", | |
431 IsValidCookieValue(pair.second)); | |
432 } | |
433 | |
428 pairs_.push_back(pair); | 434 pairs_.push_back(pair); |
429 | 435 |
430 // We've processed a token/value pair, we're either at the end of | 436 // We've processed a token/value pair, we're either at the end of |
431 // the string or a ValueSeparator like ';', which we want to skip. | 437 // the string or a ValueSeparator like ';', which we want to skip. |
432 if (it != end) | 438 if (it != end) |
433 ++it; | 439 ++it; |
434 } | 440 } |
435 } | 441 } |
436 | 442 |
437 void ParsedCookie::SetupAttributes() { | 443 void ParsedCookie::SetupAttributes() { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 --*indexes[i]; | 518 --*indexes[i]; |
513 } | 519 } |
514 pairs_.erase(pairs_.begin() + index); | 520 pairs_.erase(pairs_.begin() + index); |
515 } | 521 } |
516 | 522 |
517 bool ParsedCookie::IsSameSiteAttributeValid() const { | 523 bool ParsedCookie::IsSameSiteAttributeValid() const { |
518 return same_site_index_ == 0 || SameSite() != CookieSameSite::DEFAULT_MODE; | 524 return same_site_index_ == 0 || SameSite() != CookieSameSite::DEFAULT_MODE; |
519 } | 525 } |
520 | 526 |
521 } // namespace | 527 } // namespace |
OLD | NEW |