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

Unified Diff: net/cookies/parsed_cookie.cc

Issue 15897003: Added UMA measurement for how often we see control characters during cookie parsing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed missing brackets that were causing unit test failure. Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cookies/parsed_cookie.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/parsed_cookie.cc
diff --git a/net/cookies/parsed_cookie.cc b/net/cookies/parsed_cookie.cc
index 8d382152b32c7e12e2df45834521c4bb39c56111..a39ec84dab909e7036f0b40ec803020e2310327c 100644
--- a/net/cookies/parsed_cookie.cc
+++ b/net/cookies/parsed_cookie.cc
@@ -1,4 +1,3 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
erikwright (departed) 2013/05/24 14:15:56 Was this removed intentionally?
jww 2013/05/24 17:56:33 Nope, not at all. Fixed. On 2013/05/24 14:15:56, e
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -45,6 +44,7 @@
#include "net/cookies/parsed_cookie.h"
#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "base/string_util.h"
namespace {
@@ -130,9 +130,12 @@ bool IsValidCookieValue(const std::string& value) {
(*i >= 0x2D && *i <= 0x3A) ||
(*i >= 0x3C && *i <= 0x5B) ||
(*i >= 0x5D && *i <= 0x7E));
- if (!valid_octet)
+ if (!valid_octet) {
+ UMA_HISTOGRAM_BOOLEAN("Cookies.IsValidCookieValue", false);
erikwright (departed) 2013/05/24 14:15:56 This will be called for changing the value but not
jww 2013/05/24 17:56:33 Done.
return false;
+ }
}
+ UMA_HISTOGRAM_BOOLEAN("Cookies.IsValidCookieValue", true);
return true;
}
@@ -140,9 +143,12 @@ bool IsValidCookieAttributeValue(const std::string& value) {
// The greatest common denominator of cookie attribute values is
// <any CHAR except CTLs or ";"> according to RFC 6265.
for (std::string::const_iterator i = value.begin(); i != value.end(); ++i) {
- if ((*i >= 0 && *i <= 31) || *i == ';')
+ if ((*i >= 0 && *i <= 31) || *i == ';') {
+ UMA_HISTOGRAM_BOOLEAN("Cookies.IsValidCookieAttributeValue", false);
erikwright (departed) 2013/05/24 14:15:56 These metrics will be clouded because they cover b
jww 2013/05/24 17:56:33 The goal of this measurement is to get an overall
erikwright (departed) 2013/05/27 19:19:41 The key is checked with IsValidToken and the value
return false;
+ }
}
+ UMA_HISTOGRAM_BOOLEAN("Cookies.IsValidCookieAttributeValue", true);
return true;
}
@@ -157,7 +163,8 @@ ParsedCookie::ParsedCookie(const std::string& cookie_line)
maxage_index_(0),
secure_index_(0),
httponly_index_(0),
- priority_index_(0) {
+ priority_index_(0),
+ parsed_invalid_control_char_(false) {
if (cookie_line.size() > kMaxCookieSize) {
VLOG(1) << "Not parsing cookie, too large: " << cookie_line.size();
@@ -165,6 +172,8 @@ ParsedCookie::ParsedCookie(const std::string& cookie_line)
}
ParseTokenValuePairs(cookie_line);
+ UMA_HISTOGRAM_BOOLEAN("Cookies.ParsedInvalidControlCharacter",
+ parsed_invalid_control_char_);
if (!pairs_.empty())
SetupAttributes();
}
@@ -381,8 +390,14 @@ void ParsedCookie::ParseTokenValuePairs(const std::string& cookie_line) {
// OK, now try to parse a value.
std::string::const_iterator value_start, value_end;
ParseValue(&it, end, &value_start, &value_end);
+
+ std::string value(value_start, value_end);
+
+ if (!IsValidCookieAttributeValue(value))
erikwright (departed) 2013/05/24 14:15:56 Why not just put this after the assignment to pair
erikwright (departed) 2013/05/24 14:15:56 Note that the call to IsValidCookieAttributeValue
jww 2013/05/24 17:56:33 Done.
jww 2013/05/24 17:56:33 See my other responses. We want to measure a coupl
+ parsed_invalid_control_char_ = true;
erikwright (departed) 2013/05/24 14:15:56 I suggest converting this to a local boolean and d
palmer 2013/05/24 17:38:43 I'll second that.
jww 2013/05/24 17:56:33 Done.
jww 2013/05/24 17:56:33 Done.
+
// OK, we're finished with a Token/Value.
- pair.second = std::string(value_start, value_end);
+ pair.second = value;
// From RFC2109: "Attributes (names) (attr) are case-insensitive."
if (pair_num != 0)
« no previous file with comments | « net/cookies/parsed_cookie.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698