OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "net/quic/spdy_utils.h" | 5 #include "net/quic/spdy_utils.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 bool SpdyUtils::CopyAndValidateHeaders(const QuicHeaderList& header_list, | 113 bool SpdyUtils::CopyAndValidateHeaders(const QuicHeaderList& header_list, |
114 int64_t* content_length, | 114 int64_t* content_length, |
115 SpdyHeaderBlock* headers) { | 115 SpdyHeaderBlock* headers) { |
116 for (const auto& p : header_list) { | 116 for (const auto& p : header_list) { |
117 const string& name = p.first; | 117 const string& name = p.first; |
118 if (name.empty()) { | 118 if (name.empty()) { |
119 DVLOG(1) << "Header name must not be empty."; | 119 DVLOG(1) << "Header name must not be empty."; |
120 return false; | 120 return false; |
121 } | 121 } |
122 | 122 |
| 123 if (std::any_of(name.begin(), name.end(), base::IsAsciiUpper<char>)) { |
| 124 DLOG(ERROR) << "Malformed header: Header name " << name |
| 125 << " contains upper-case characters."; |
| 126 return false; |
| 127 } |
| 128 |
123 auto iter = headers->find(name); | 129 auto iter = headers->find(name); |
124 if (iter == headers->end()) { | 130 if (iter == headers->end()) { |
125 (*headers)[name] = p.second; | 131 (*headers)[name] = p.second; |
126 } else if (name == "cookie") { | 132 } else if (name == "cookie") { |
127 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction. | 133 // Obeys section 8.1.2.5 in RFC 7540 for cookie reconstruction. |
128 headers->ReplaceOrAppendHeader( | 134 headers->ReplaceOrAppendHeader( |
129 name, base::StringPrintf("%s; %s", iter->second.as_string().c_str(), | 135 name, base::StringPrintf("%s; %s", iter->second.as_string().c_str(), |
130 p.second.c_str())); | 136 p.second.c_str())); |
131 } else { | 137 } else { |
132 // This header had multiple values, so it must be reconstructed. | 138 // This header had multiple values, so it must be reconstructed. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 return GURL(GetUrlFromHeaderBlock(headers)).host(); | 248 return GURL(GetUrlFromHeaderBlock(headers)).host(); |
243 } | 249 } |
244 | 250 |
245 // static | 251 // static |
246 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { | 252 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { |
247 string url(GetUrlFromHeaderBlock(headers)); | 253 string url(GetUrlFromHeaderBlock(headers)); |
248 return url != "" && GURL(url).is_valid(); | 254 return url != "" && GURL(url).is_valid(); |
249 } | 255 } |
250 | 256 |
251 } // namespace net | 257 } // namespace net |
OLD | NEW |