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

Unified Diff: net/http/http_request_headers.cc

Issue 2428103002: Escape non-ASCII Request header values before attaching them as a NetLog string. (Closed)
Patch Set: Address Matt's feedback 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 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/http/http_request_headers.cc
diff --git a/net/http/http_request_headers.cc b/net/http/http_request_headers.cc
index 8e667fc4886f854a1566d95ae5c2552e1756426f..70f6d27a95698fcabe3e900fa8a0fe9acd8175d6 100644
--- a/net/http/http_request_headers.cc
+++ b/net/http/http_request_headers.cc
@@ -11,6 +11,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
+#include "net/base/escape.h"
#include "net/http/http_log_util.h"
#include "net/http/http_util.h"
#include "net/log/net_log_capture_mode.h"
@@ -188,14 +189,16 @@ std::unique_ptr<base::Value> HttpRequestHeaders::NetLogCallback(
const std::string* request_line,
NetLogCaptureMode capture_mode) const {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- dict->SetString("line", *request_line);
+ dict->SetString("line", EscapeNonASCII(*request_line));
base::ListValue* headers = new base::ListValue();
- for (HeaderVector::const_iterator it = headers_.begin();
- it != headers_.end(); ++it) {
+ for (HeaderVector::const_iterator it = headers_.begin(); it != headers_.end();
+ ++it) {
std::string log_value =
ElideHeaderValueForNetLog(capture_mode, it->key, it->value);
- headers->AppendString(
- base::StringPrintf("%s: %s", it->key.c_str(), log_value.c_str()));
+ std::string escaped_name = EscapeNonASCII(it->key);
+ std::string escaped_value = EscapeNonASCII(log_value);
+ headers->AppendString(base::StringPrintf("%s: %s", escaped_name.c_str(),
+ escaped_value.c_str()));
}
dict->Set("headers", headers);
return std::move(dict);
« 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