From f9487601c410591159203d1acc9c4f1372534f4b Mon Sep 17 00:00:00 2001 From: pkasting Date: Wed, 6 May 2015 13:26:54 -0700 Subject: Relax the canonical host requirements yet further. Apparently there are sites using "_" as a standalone host component. Ugh. BUG=324310 TEST=Type "_.bjb.io" (no quotes) into the address bar and check that the default action is to navigate Review URL: https://codereview.chromium.org/1119173004 Cr-Commit-Position: refs/heads/master@{#328600} --- net/base/net_util.cc | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'net/base/net_util.cc') diff --git a/net/base/net_util.cc b/net/base/net_util.cc index d304897..26868a0 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -258,27 +258,20 @@ bool IsCanonicalizedHostCompliant(const std::string& host) { bool in_component = false; bool most_recent_component_started_alphanumeric = false; - bool last_char_was_underscore = false; for (std::string::const_iterator i(host.begin()); i != host.end(); ++i) { const char c = *i; if (!in_component) { most_recent_component_started_alphanumeric = IsHostCharAlphanumeric(c); - if (!most_recent_component_started_alphanumeric && (c != '-')) - return false; - in_component = true; - } else { - if (c == '.') { - if (last_char_was_underscore) - return false; - in_component = false; - } else if (IsHostCharAlphanumeric(c) || (c == '-')) { - last_char_was_underscore = false; - } else if (c == '_') { - last_char_was_underscore = true; - } else { + if (!most_recent_component_started_alphanumeric && (c != '-') && + (c != '_')) { return false; } + in_component = true; + } else if (c == '.') { + in_component = false; + } else if (!IsHostCharAlphanumeric(c) && (c != '-') && (c != '_')) { + return false; } } -- cgit v1.1