| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/proxy/proxy_bypass_rules.h" | 5 #include "net/proxy/proxy_bypass_rules.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/pattern.h" | 8 #include "base/strings/pattern.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 new BypassIPBlockRule(raw, scheme, ip_prefix, prefix_length_in_bits)); | 294 new BypassIPBlockRule(raw, scheme, ip_prefix, prefix_length_in_bits)); |
| 295 | 295 |
| 296 return true; | 296 return true; |
| 297 } | 297 } |
| 298 | 298 |
| 299 // Check if we have an <ip-address>[:port] input. We need to treat this | 299 // Check if we have an <ip-address>[:port] input. We need to treat this |
| 300 // separately since the IP literal may not be in a canonical form. | 300 // separately since the IP literal may not be in a canonical form. |
| 301 std::string host; | 301 std::string host; |
| 302 int port; | 302 int port; |
| 303 if (ParseHostAndPort(raw, &host, &port)) { | 303 if (ParseHostAndPort(raw, &host, &port)) { |
| 304 // TODO(eroman): HostForURL() below DCHECKs() when |host| contains an |
| 305 // embedded NULL. |
| 306 if (host.find('\0') != std::string::npos) |
| 307 return false; |
| 308 |
| 304 // Note that HostPortPair is used to merely to convert any IPv6 literals to | 309 // Note that HostPortPair is used to merely to convert any IPv6 literals to |
| 305 // a URL-safe format that can be used by canonicalization below. | 310 // a URL-safe format that can be used by canonicalization below. |
| 306 std::string bracketed_host = HostPortPair(host, 80).HostForURL(); | 311 std::string bracketed_host = HostPortPair(host, 80).HostForURL(); |
| 307 if (IsIPAddress(bracketed_host)) { | 312 if (IsIPAddress(bracketed_host)) { |
| 308 // Canonicalize the IP literal before adding it as a string pattern. | 313 // Canonicalize the IP literal before adding it as a string pattern. |
| 309 GURL tmp_url("http://" + bracketed_host); | 314 GURL tmp_url("http://" + bracketed_host); |
| 310 return AddRuleForHostname(scheme, tmp_url.host(), port); | 315 return AddRuleForHostname(scheme, tmp_url.host(), port); |
| 311 } | 316 } |
| 312 } | 317 } |
| 313 | 318 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 339 return AddRuleForHostname(scheme, raw, port); | 344 return AddRuleForHostname(scheme, raw, port); |
| 340 } | 345 } |
| 341 | 346 |
| 342 bool ProxyBypassRules::AddRuleFromStringInternalWithLogging( | 347 bool ProxyBypassRules::AddRuleFromStringInternalWithLogging( |
| 343 const std::string& raw, | 348 const std::string& raw, |
| 344 bool use_hostname_suffix_matching) { | 349 bool use_hostname_suffix_matching) { |
| 345 return AddRuleFromStringInternal(raw, use_hostname_suffix_matching); | 350 return AddRuleFromStringInternal(raw, use_hostname_suffix_matching); |
| 346 } | 351 } |
| 347 | 352 |
| 348 } // namespace net | 353 } // namespace net |
| OLD | NEW |