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

Unified Diff: net/proxy/proxy_bypass_rules.cc

Issue 602973002: Change ParseHostAndPort() to not include brackets around IPv6 literals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a comment Created 6 years, 3 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 | « net/base/net_util_unittest.cc ('k') | net/proxy/proxy_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_bypass_rules.cc
diff --git a/net/proxy/proxy_bypass_rules.cc b/net/proxy/proxy_bypass_rules.cc
index 6bf1c6157e560e3fa72b1df152affcb037f962a7..239a2fe30c5f0c482f34a546aadeebcb397a11d8 100644
--- a/net/proxy/proxy_bypass_rules.cc
+++ b/net/proxy/proxy_bypass_rules.cc
@@ -6,10 +6,11 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_tokenizer.h"
+#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "net/base/host_port_pair.h"
#include "net/base/net_util.h"
namespace net {
@@ -131,6 +132,7 @@ class BypassIPBlockRule : public ProxyBypassRules::Rule {
};
// Returns true if the given string represents an IP address.
+// IPv6 addresses are expected to be bracketed.
bool IsIPAddress(const std::string& domain) {
// From GURL::HostIsIPAddress()
url::RawCanonOutputT<char, 128> ignored_output;
@@ -305,9 +307,12 @@ bool ProxyBypassRules::AddRuleFromStringInternal(
std::string host;
int port;
if (ParseHostAndPort(raw, &host, &port)) {
- if (IsIPAddress(host)) {
+ // Note that HostPortPair is used to merely to convert any IPv6 literals to
+ // a URL-safe format that can be used by canonicalization below.
+ std::string bracketed_host = HostPortPair(host, 80).HostForURL();
+ if (IsIPAddress(bracketed_host)) {
// Canonicalize the IP literal before adding it as a string pattern.
- GURL tmp_url("http://" + host);
+ GURL tmp_url("http://" + bracketed_host);
return AddRuleForHostname(scheme, tmp_url.host(), port);
}
}
« no previous file with comments | « net/base/net_util_unittest.cc ('k') | net/proxy/proxy_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698