diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-30 00:20:32 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-30 00:20:32 +0000 |
commit | 4848bbbc2f355aafe577ec211d36c4ae28a61c9b (patch) | |
tree | 6240ef01cb2e02c4d735226203179bcf692ec03a /net/base/net_util.cc | |
parent | 79847cf448d8648e00029868936dc8b14904b9f7 (diff) | |
download | chromium_src-4848bbbc2f355aafe577ec211d36c4ae28a61c9b.zip chromium_src-4848bbbc2f355aafe577ec211d36c4ae28a61c9b.tar.gz chromium_src-4848bbbc2f355aafe577ec211d36c4ae28a61c9b.tar.bz2 |
Relax IsCanonicalizedHostCompliant again: allow the last component to start with
an alphanumeric character, not just an alphabetic one.
BUG=262206
TEST=Type "http://9a" in the omnibox, default choice should be to navigate
R=eroman@chromium.org
Review URL: https://codereview.chromium.org/21077005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214272 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util.cc')
-rw-r--r-- | net/base/net_util.cc | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 50766dd..3ca0d99 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -1024,14 +1024,10 @@ std::string GetDirectoryListingHeader(const base::string16& title) { return result; } -inline bool IsHostCharAlpha(char c) { +inline bool IsHostCharAlphanumeric(char c) { // We can just check lowercase because uppercase characters have already been // normalized. - return (c >= 'a') && (c <= 'z'); -} - -inline bool IsHostCharDigit(char c) { - return (c >= '0') && (c <= '9'); + return ((c >= 'a') && (c <= 'z')) || ((c >= '0') && (c <= '9')); } bool IsCanonicalizedHostCompliant(const std::string& host, @@ -1040,15 +1036,14 @@ bool IsCanonicalizedHostCompliant(const std::string& host, return false; bool in_component = false; - bool most_recent_component_started_alpha = 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_alpha = IsHostCharAlpha(c); - if (!most_recent_component_started_alpha && !IsHostCharDigit(c) && - (c != '-')) + most_recent_component_started_alphanumeric = IsHostCharAlphanumeric(c); + if (!most_recent_component_started_alphanumeric && (c != '-')) return false; in_component = true; } else { @@ -1056,7 +1051,7 @@ bool IsCanonicalizedHostCompliant(const std::string& host, if (last_char_was_underscore) return false; in_component = false; - } else if (IsHostCharAlpha(c) || IsHostCharDigit(c) || (c == '-')) { + } else if (IsHostCharAlphanumeric(c) || (c == '-')) { last_char_was_underscore = false; } else if (c == '_') { last_char_was_underscore = true; @@ -1066,8 +1061,8 @@ bool IsCanonicalizedHostCompliant(const std::string& host, } } - return most_recent_component_started_alpha || - (!desired_tld.empty() && IsHostCharAlpha(desired_tld[0])); + return most_recent_component_started_alphanumeric || + (!desired_tld.empty() && IsHostCharAlphanumeric(desired_tld[0])); } std::string GetDirectoryListingEntry(const base::string16& name, |