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

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: Erik changes as well as additional measurement of invalid tokens during cookie line parsing. 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 | « no previous file | 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..533a3e65d975c3fe15d3e9d7c30bdc44e58047a9 100644
--- a/net/cookies/parsed_cookie.cc
+++ b/net/cookies/parsed_cookie.cc
@@ -45,6 +45,7 @@
#include "net/cookies/parsed_cookie.h"
#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "base/string_util.h"
namespace {
@@ -182,20 +183,26 @@ CookiePriority ParsedCookie::Priority() const {
}
bool ParsedCookie::SetName(const std::string& name) {
- if (!IsValidToken(name))
+ if (!IsValidToken(name)) {
+ UMA_HISTOGRAM_BOOLEAN("Cookies.SetNameInvalidToken", true);
return false;
+ }
if (pairs_.empty())
pairs_.push_back(std::make_pair("", ""));
pairs_[0].first = name;
+ UMA_HISTOGRAM_BOOLEAN("Cookies.SetNameInvalidToken", false);
return true;
}
bool ParsedCookie::SetValue(const std::string& value) {
- if (!IsValidCookieValue(value))
+ if (!IsValidCookieValue(value)) {
+ UMA_HISTOGRAM_BOOLEAN("Cookies.SetValueInvalidCookieValue", true);
return false;
+ }
if (pairs_.empty())
pairs_.push_back(std::make_pair("", ""));
pairs_[0].second = value;
+ UMA_HISTOGRAM_BOOLEAN("Cookies.SetValueInvalidCookieValue", false);
return true;
}
@@ -337,6 +344,9 @@ std::string ParsedCookie::ParseValueString(const std::string& value) {
// Parse all token/value pairs and populate pairs_.
void ParsedCookie::ParseTokenValuePairs(const std::string& cookie_line) {
+ bool parsed_invalid_control_char = false;
+ bool parsed_invalid_token = false;
+
pairs_.clear();
// Ok, here we go. We should be expecting to be starting somewhere
@@ -384,6 +394,11 @@ void ParsedCookie::ParseTokenValuePairs(const std::string& cookie_line) {
// OK, we're finished with a Token/Value.
pair.second = std::string(value_start, value_end);
+ if (!IsValidCookieAttributeValue(pair.second))
+ parsed_invalid_control_char = true;
+ if (!IsValidToken(pair.second))
+ parsed_invalid_token = true;
+
// From RFC2109: "Attributes (names) (attr) are case-insensitive."
if (pair_num != 0)
StringToLowerASCII(&pair.first);
@@ -394,6 +409,10 @@ void ParsedCookie::ParseTokenValuePairs(const std::string& cookie_line) {
if (it != end)
++it;
}
+
+ UMA_HISTOGRAM_BOOLEAN("Cookies.ParsedInvalidControlCharacter",
+ parsed_invalid_control_char);
erikwright (departed) 2013/05/27 19:19:41 indentation (align with ")
jww 2013/05/28 17:14:05 Done.
+ UMA_HISTOGRAM_BOOLEAN("Cookies.ParsedInvalidToken", parsed_invalid_token);
}
void ParsedCookie::SetupAttributes() {
@@ -444,8 +463,11 @@ bool ParsedCookie::SetBool(size_t* index,
bool ParsedCookie::SetAttributePair(size_t* index,
const std::string& key,
const std::string& value) {
- if (!IsValidToken(key) || !IsValidCookieAttributeValue(value))
+ if (!IsValidToken(key) || !IsValidCookieAttributeValue(value)) {
+ UMA_HISTOGRAM_BOOLEAN("Cookies.SetAttributePairInvalidChars", true);
return false;
+ }
+ UMA_HISTOGRAM_BOOLEAN("Cookies.SetAttributePairInvalidChars", false);
if (!IsValid())
return false;
if (*index) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698