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

Side by Side Diff: net/http/http_util.cc

Issue 2101963002: Skip header lines with invalid header name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/http/http_util_unittest.cc » ('j') | net/http/http_util_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The rules for parsing content-types were borrowed from Firefox: 5 // The rules for parsing content-types were borrowed from Firefox:
6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834
7 7
8 #include "net/http/http_util.h" 8 #include "net/http/http_util.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 903
904 name_end_ = colon; 904 name_end_ = colon;
905 905
906 // If the name starts with LWS, it is an invalid line. 906 // If the name starts with LWS, it is an invalid line.
907 // Leading LWS implies a line continuation, and these should have 907 // Leading LWS implies a line continuation, and these should have
908 // already been joined by AssembleRawHeaders(). 908 // already been joined by AssembleRawHeaders().
909 if (name_begin_ == name_end_ || IsLWS(*name_begin_)) 909 if (name_begin_ == name_end_ || IsLWS(*name_begin_))
910 continue; 910 continue;
911 911
912 TrimLWS(&name_begin_, &name_end_); 912 TrimLWS(&name_begin_, &name_end_);
913 if (name_begin_ == name_end_) 913 if (!IsToken(name_begin_, name_end_))
mmenke 2016/06/28 14:54:00 IsValidHeaderName seems clearer (It just calls IsT
robwu 2016/06/28 15:24:42 IsValidHeaderName takes a std::string, while we on
mmenke 2016/06/28 15:26:17 Oops, good point.
914 continue; // skip malformed header 914 continue; // skip malformed header
915 915
916 values_begin_ = colon + 1; 916 values_begin_ = colon + 1;
917 TrimLWS(&values_begin_, &values_end_); 917 TrimLWS(&values_begin_, &values_end_);
918 918
919 // if we got a header name, then we are done. 919 // if we got a header name, then we are done.
920 return true; 920 return true;
921 } 921 }
922 return false; 922 return false;
923 } 923 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 return true; 1072 return true;
1073 } 1073 }
1074 1074
1075 bool HttpUtil::NameValuePairsIterator::IsQuote(char c) const { 1075 bool HttpUtil::NameValuePairsIterator::IsQuote(char c) const {
1076 if (strict_quotes_) 1076 if (strict_quotes_)
1077 return c == '"'; 1077 return c == '"';
1078 return HttpUtil::IsQuote(c); 1078 return HttpUtil::IsQuote(c);
1079 } 1079 }
1080 1080
1081 } // namespace net 1081 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_util_unittest.cc » ('j') | net/http/http_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698