| OLD | NEW |
| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 340 } |
| 341 | 341 |
| 342 // static | 342 // static |
| 343 bool HttpUtil::IsValidHeaderName(const std::string& name) { | 343 bool HttpUtil::IsValidHeaderName(const std::string& name) { |
| 344 // Check whether the header name is RFC 2616-compliant. | 344 // Check whether the header name is RFC 2616-compliant. |
| 345 return HttpUtil::IsToken(name); | 345 return HttpUtil::IsToken(name); |
| 346 } | 346 } |
| 347 | 347 |
| 348 // static | 348 // static |
| 349 bool HttpUtil::IsValidHeaderValue(const std::string& value) { | 349 bool HttpUtil::IsValidHeaderValue(const std::string& value) { |
| 350 // Just a sanity check: disallow NUL and CRLF. | 350 // Just a sanity check: disallow NUL, CR and LF. |
| 351 return value.find('\0') == std::string::npos && | 351 return value.find_first_of("\0\r\n", 0, 3) == std::string::npos; |
| 352 value.find("\r\n") == std::string::npos; | |
| 353 } | 352 } |
| 354 | 353 |
| 355 // static | 354 // static |
| 356 std::string HttpUtil::StripHeaders(const std::string& headers, | 355 std::string HttpUtil::StripHeaders(const std::string& headers, |
| 357 const char* const headers_to_remove[], | 356 const char* const headers_to_remove[], |
| 358 size_t headers_to_remove_len) { | 357 size_t headers_to_remove_len) { |
| 359 std::string stripped_headers; | 358 std::string stripped_headers; |
| 360 HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\r\n"); | 359 HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\r\n"); |
| 361 | 360 |
| 362 while (it.GetNext()) { | 361 while (it.GetNext()) { |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 return true; | 1053 return true; |
| 1055 } | 1054 } |
| 1056 | 1055 |
| 1057 bool HttpUtil::NameValuePairsIterator::IsQuote(char c) const { | 1056 bool HttpUtil::NameValuePairsIterator::IsQuote(char c) const { |
| 1058 if (strict_quotes_) | 1057 if (strict_quotes_) |
| 1059 return c == '"'; | 1058 return c == '"'; |
| 1060 return HttpUtil::IsQuote(c); | 1059 return HttpUtil::IsQuote(c); |
| 1061 } | 1060 } |
| 1062 | 1061 |
| 1063 } // namespace net | 1062 } // namespace net |
| OLD | NEW |