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

Unified Diff: net/base/net_util.cc

Issue 1629733002: net: move IsHostnameNonUnique() into url_util.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix ssl_errors Created 4 years, 11 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.h ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_util.cc
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index ef178b253a2095e2ecebda0f293a4f437a88c587..0a93463254fc2ae1108b2f28a08ddb116e9f4f32 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -14,9 +14,6 @@
#include "base/strings/string_util.h"
#include "net/base/address_list.h"
#include "net/base/ip_address_number.h"
-#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
-#include "net/base/url_util.h"
-#include "url/url_canon_ip.h"
#if defined(OS_WIN)
#include "net/base/winsock_init.h"
@@ -50,52 +47,6 @@ bool IsLocal6Hostname(const std::string& host) {
} // namespace
-bool IsHostnameNonUnique(const std::string& hostname) {
- // CanonicalizeHost requires surrounding brackets to parse an IPv6 address.
- const std::string host_or_ip = hostname.find(':') != std::string::npos ?
- "[" + hostname + "]" : hostname;
- url::CanonHostInfo host_info;
- std::string canonical_name = CanonicalizeHost(host_or_ip, &host_info);
-
- // If canonicalization fails, then the input is truly malformed. However,
- // to avoid mis-reporting bad inputs as "non-unique", treat them as unique.
- if (canonical_name.empty())
- return false;
-
- // If |hostname| is an IP address, check to see if it's in an IANA-reserved
- // range.
- if (host_info.IsIPAddress()) {
- IPAddressNumber host_addr;
- if (!ParseIPLiteralToNumber(hostname.substr(host_info.out_host.begin,
- host_info.out_host.len),
- &host_addr)) {
- return false;
- }
- switch (host_info.family) {
- case url::CanonHostInfo::IPV4:
- case url::CanonHostInfo::IPV6:
- return IsIPAddressReserved(host_addr);
- case url::CanonHostInfo::NEUTRAL:
- case url::CanonHostInfo::BROKEN:
- return false;
- }
- }
-
- // Check for a registry controlled portion of |hostname|, ignoring private
- // registries, as they already chain to ICANN-administered registries,
- // and explicitly ignoring unknown registries.
- //
- // Note: This means that as new gTLDs are introduced on the Internet, they
- // will be treated as non-unique until the registry controlled domain list
- // is updated. However, because gTLDs are expected to provide significant
- // advance notice to deprecate older versions of this code, this an
- // acceptable tradeoff.
- return 0 == registry_controlled_domains::GetRegistryLength(
- canonical_name,
- registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
- registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
-}
-
std::string GetHostName() {
#if defined(OS_NACL)
NOTIMPLEMENTED();
« no previous file with comments | « net/base/net_util.h ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698