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

Unified Diff: net/http/http_content_disposition.cc

Issue 2225933004: Avoid adding invalid headers in AddHeaderFromString (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove IsToken(iterator, iterator) overload 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 | « no previous file | net/http/http_request_headers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_content_disposition.cc
diff --git a/net/http/http_content_disposition.cc b/net/http/http_content_disposition.cc
index 3f7d6b5f8a13b594b5015bc1b123cae80fc2527b..eb59b6d232bc3ea1eccb761947a2916a5c2f69e0 100644
--- a/net/http/http_content_disposition.cc
+++ b/net/http/http_content_disposition.cc
@@ -6,6 +6,7 @@
#include "base/base64.h"
#include "base/logging.h"
+#include "base/strings/string_piece.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
@@ -353,8 +354,11 @@ std::string::const_iterator HttpContentDisposition::ConsumeDispositionType(
// If the disposition-type isn't a valid token the then the
// Content-Disposition header is malformed, and we treat the first bytes as
// a parameter rather than a disposition-type.
- if (!HttpUtil::IsToken(type_begin, type_end))
+ if (type_begin == type_end ||
+ !HttpUtil::IsToken(
+ base::StringPiece(&*type_begin, type_end - type_begin))) {
return begin;
+ }
parse_result_flags_ |= HAS_DISPOSITION_TYPE;
« no previous file with comments | « no previous file | net/http/http_request_headers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698