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

Unified Diff: net/http/http_util.cc

Issue 491123004: Make sure that HttpRequestHeaders contains valid key-value pairs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: edit comment Created 6 years, 4 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/http/http_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util.cc
diff --git a/net/http/http_util.cc b/net/http/http_util.cc
index 224ae6c4709eff000b3ac67bc5e18955dffce29c..4574c7fd25f661e4259ac9af7b507eec4fb0191b 100644
--- a/net/http/http_util.cc
+++ b/net/http/http_util.cc
@@ -340,6 +340,19 @@ bool HttpUtil::IsSafeHeader(const std::string& name) {
}
// static
+bool HttpUtil::IsValidHeaderName(const std::string& name) {
+ // Check whether the header name is RFC 2616-compliant.
+ return HttpUtil::IsToken(name);
+}
+
+// static
+bool HttpUtil::IsValidHeaderValue(const std::string& value) {
+ // Just a sanity check: disallow NUL and CRLF.
+ return value.find('\0') == std::string::npos &&
+ value.find("\r\n") == std::string::npos;
+}
+
+// static
std::string HttpUtil::StripHeaders(const std::string& headers,
const char* const headers_to_remove[],
size_t headers_to_remove_len) {
« no previous file with comments | « net/http/http_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698