summaryrefslogtreecommitdiffstats
path: root/net/base/net_util.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 18:17:26 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-03 18:17:26 +0000
commitd120c37264be4ed06b52e64acd390939ebe6e13e (patch)
tree578eca4ce2fd5cf9602a568f457f2ad4e1fb4dc9 /net/base/net_util.cc
parent20824e8b140ef43bac73e0fa70c55257333b271f (diff)
downloadchromium_src-d120c37264be4ed06b52e64acd390939ebe6e13e.zip
chromium_src-d120c37264be4ed06b52e64acd390939ebe6e13e.tar.gz
chromium_src-d120c37264be4ed06b52e64acd390939ebe6e13e.tar.bz2
Allow trailing dots on hostnames.
BUG=25962 TEST=Type in "google.com." and verify you can navigate. Review URL: http://codereview.chromium.org/340070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util.cc')
-rw-r--r--net/base/net_util.cc21
1 files changed, 8 insertions, 13 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index 5c91a68..9715aa0e 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -965,27 +965,22 @@ bool IsCanonicalizedHostCompliant(const std::string& host) {
if (host.empty())
return false;
- enum State {
- NOT_IN_COMPONENT,
- IN_COMPONENT_STARTED_DIGIT,
- IN_COMPONENT_STARTED_ALPHA
- } state = NOT_IN_COMPONENT;
+ bool in_component = false;
+ bool most_recent_component_started_alpha = false;
bool last_char_was_hyphen_or_underscore = false;
for (std::string::const_iterator i(host.begin()); i != host.end(); ++i) {
const char c = *i;
- if (state == NOT_IN_COMPONENT) {
- if (IsHostCharDigit(c))
- state = IN_COMPONENT_STARTED_DIGIT;
- else if (IsHostCharAlpha(c))
- state = IN_COMPONENT_STARTED_ALPHA;
- else
+ if (!in_component) {
+ most_recent_component_started_alpha = IsHostCharAlpha(c);
+ if (!most_recent_component_started_alpha && !IsHostCharDigit(c))
return false;
+ in_component = true;
} else {
if (c == '.') {
if (last_char_was_hyphen_or_underscore)
return false;
- state = NOT_IN_COMPONENT;
+ in_component = false;
} else if (IsHostCharAlpha(c) || IsHostCharDigit(c)) {
last_char_was_hyphen_or_underscore = false;
} else if ((c == '-') || (c == '_')) {
@@ -996,7 +991,7 @@ bool IsCanonicalizedHostCompliant(const std::string& host) {
}
}
- return state == IN_COMPONENT_STARTED_ALPHA;
+ return most_recent_component_started_alpha;
}
std::string GetDirectoryListingEntry(const string16& name,