summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authorjschuh@google.com <jschuh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-08 19:29:41 +0000
committerjschuh@google.com <jschuh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-08 19:29:41 +0000
commit13c340e130d5fa54b3abe5f3001bda94d4569009 (patch)
treec52af4b32d11fc2be00340e867ea155648b03fbc /net/base
parentc3df17c94b05b3a22b6755b93dc68bcca9c010f7 (diff)
downloadchromium_src-13c340e130d5fa54b3abe5f3001bda94d4569009.zip
chromium_src-13c340e130d5fa54b3abe5f3001bda94d4569009.tar.gz
chromium_src-13c340e130d5fa54b3abe5f3001bda94d4569009.tar.bz2
Correctly handle trailing dots in hostname blacklist.
Submitted for inferno@chromium.org BUG=35510 TEST=HostContentSettingsMapTest.HostTrimEndingDotCheck Review URL: http://codereview.chromium.org/669284 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40921 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r--net/base/dns_util.cc8
-rw-r--r--net/base/dns_util.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/net/base/dns_util.cc b/net/base/dns_util.cc
index db5f606..87d1866 100644
--- a/net/base/dns_util.cc
+++ b/net/base/dns_util.cc
@@ -70,4 +70,12 @@ bool IsSTD3ASCIIValidCharacter(char c) {
return true;
}
+std::string TrimEndingDot(const std::string& host) {
+ std::string host_trimmed = host;
+ size_t len = host_trimmed.length();
+ if (len > 1 && host_trimmed[len - 1] == '.')
+ host_trimmed.erase(len - 1);
+ return host_trimmed;
+}
+
} // namespace net
diff --git a/net/base/dns_util.h b/net/base/dns_util.h
index 8eb98f2..f0d2051 100644
--- a/net/base/dns_util.h
+++ b/net/base/dns_util.h
@@ -20,6 +20,9 @@ bool DNSDomainFromDot(const std::string& dotted, std::string* out);
// characters as given in RFC 3490, 4.1, 3(a)
bool IsSTD3ASCIIValidCharacter(char c);
+// Returns the hostname by trimming the ending dot, if one exists.
+std::string TrimEndingDot(const std::string& host);
+
} // namespace net
#endif // NET_BASE_DNS_UTIL_H_