Index: net/base/net_util.cc |
diff --git a/net/base/net_util.cc b/net/base/net_util.cc |
index 3b49dffb5c20d889003a09755276ddaa8e41542d..a16d9e7116bd45f70d19bcf114b803e870de63a3 100644 |
--- a/net/base/net_util.cc |
+++ b/net/base/net_util.cc |
@@ -144,6 +144,9 @@ static const int kAllowedFtpPorts[] = { |
22, // ssh |
}; |
+static const char kLocalhostTLD[] = ".localhost"; |
+static const int kLocalhostTLDLength = strlen(kLocalhostTLD); |
+ |
bool IPNumberPrefixCheck(const IPAddressNumber& ip_number, |
const unsigned char* ip_prefix, |
size_t prefix_length_in_bits) { |
@@ -984,7 +987,8 @@ bool IsLocalhost(const std::string& host) { |
if (host == "localhost" || |
host == "localhost.localdomain" || |
host == "localhost6" || |
- host == "localhost6.localdomain6") |
+ host == "localhost6.localdomain6" || |
+ IsLocalhostTLD(host)) |
return true; |
IPAddressNumber ip_number; |
@@ -1014,6 +1018,14 @@ bool IsLocalhost(const std::string& host) { |
return false; |
} |
+bool IsLocalhostTLD(const std::string& host) { |
Ryan Sleevi
2015/02/19 22:24:56
I guess it depends on the rules for |host| here, b
estark
2015/02/20 01:55:19
Gotcha. Done in this function, and filed another b
|
+ int host_length = host.length(); |
Ryan Sleevi
2015/02/19 22:24:56
s/int/size_t/ - right numeric for the job
estark
2015/02/20 01:55:19
Done.
|
+ if (host_length < kLocalhostTLDLength) |
+ return false; |
+ return host.compare(host_length - kLocalhostTLDLength, std::string::npos, |
+ kLocalhostTLD) == 0; |
+} |
+ |
NetworkInterface::NetworkInterface() |
: type(NetworkChangeNotifier::CONNECTION_UNKNOWN), prefix_length(0) { |
} |