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

Unified Diff: net/http/http_util.h

Issue 2225933004: Avoid adding invalid headers in AddHeaderFromString (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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_request_headers.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util.h
diff --git a/net/http/http_util.h b/net/http/http_util.h
index 77706f1afea39a9f15695247298b4243468c4061..527f659371552a074e40005356ac7f9fd1ab0302 100644
--- a/net/http/http_util.h
+++ b/net/http/http_util.h
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/strings/string_piece.h"
#include "base/strings/string_tokenizer.h"
#include "base/time/time.h"
#include "net/base/net_export.h"
@@ -77,11 +78,11 @@ class NET_EXPORT HttpUtil {
static bool IsSafeHeader(const std::string& name);
// Returns true if |name| is a valid HTTP header name.
- static bool IsValidHeaderName(const std::string& name);
+ static bool IsValidHeaderName(const base::StringPiece& name);
// Returns false if |value| contains NUL or CRLF. This method does not perform
// a fully RFC-2616-compliant header value validation.
- static bool IsValidHeaderValue(const std::string& value);
+ static bool IsValidHeaderValue(const base::StringPiece& value);
// Strips all header lines from |headers| whose name matches
// |headers_to_remove|. |headers_to_remove| is a list of null-terminated
@@ -108,16 +109,13 @@ class NET_EXPORT HttpUtil {
// Trim HTTP_LWS chars from the beginning and end of the string.
static void TrimLWS(std::string::const_iterator* begin,
std::string::const_iterator* end);
+ static base::StringPiece TrimLWS(const base::StringPiece& string);
// Whether the character is the start of a quotation mark.
static bool IsQuote(char c);
// Whether the string is a valid |token| as defined in RFC 2616 Sec 2.2.
- static bool IsToken(std::string::const_iterator begin,
- std::string::const_iterator end);
- static bool IsToken(const std::string& str) {
- return IsToken(str.begin(), str.end());
- }
+ static bool IsToken(const base::StringPiece& str);
// Whether the string is a valid |parmname| as defined in RFC 5987 Sec 3.2.1.
static bool IsParmName(std::string::const_iterator begin,
« no previous file with comments | « net/http/http_request_headers.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698