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

Unified Diff: components/ssl_errors/error_classification.cc

Issue 2456643005: Reduce buggy usage of the registry controlled domain service. (Closed)
Patch Set: Fix Created 4 years, 2 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
Index: components/ssl_errors/error_classification.cc
diff --git a/components/ssl_errors/error_classification.cc b/components/ssl_errors/error_classification.cc
index c61b3262aca91ceeb9df8e5f83ba5a1fa6e209a4..572b5729528089c583738fe485b8f51de6e4c999 100644
--- a/components/ssl_errors/error_classification.cc
+++ b/components/ssl_errors/error_classification.cc
@@ -73,7 +73,7 @@ std::vector<HostnameTokens> GetTokenizedDNSNames(
for (const auto& dns_name : dns_names) {
HostnameTokens dns_name_token_single;
if (dns_name.empty() || dns_name.find('\0') != std::string::npos ||
- !(IsHostNameKnownTLD(dns_name))) {
+ !(HostNameHasKnownTLD(dns_name))) {
dns_name_token_single.push_back(std::string());
} else {
dns_name_token_single = Tokenize(dns_name);
@@ -148,7 +148,7 @@ void RecordUMAStatistics(bool overridable,
}
case ssl_errors::ErrorInfo::CERT_COMMON_NAME_INVALID: {
std::string host_name = request_url.host();
- if (IsHostNameKnownTLD(host_name)) {
+ if (HostNameHasKnownTLD(host_name)) {
HostnameTokens host_name_tokens = Tokenize(host_name);
if (IsWWWSubDomainMatch(request_url, cert))
RecordSSLInterstitialCause(overridable, WWW_SUBDOMAIN_MATCH);
@@ -278,13 +278,10 @@ void SetBuildTimeForTesting(const base::Time& testing_time) {
g_testing_build_time.Get() = testing_time;
}
-bool IsHostNameKnownTLD(const std::string& host_name) {
- size_t tld_length = net::registry_controlled_domains::GetRegistryLength(
+bool HostNameHasKnownTLD(const std::string& host_name) {
+ return net::registry_controlled_domains::HostHasRegistryControlledDomain(
host_name, net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
- if (tld_length == 0 || tld_length == std::string::npos)
- return false;
- return true;
}
HostnameTokens Tokenize(const std::string& name) {
@@ -297,12 +294,12 @@ bool GetWWWSubDomainMatch(const GURL& request_url,
std::string* www_match_host_name) {
const std::string& host_name = request_url.host();
- if (IsHostNameKnownTLD(host_name)) {
+ if (HostNameHasKnownTLD(host_name)) {
// Need to account for all possible domains given in the SSL certificate.
for (const auto& dns_name : dns_names) {
if (dns_name.empty() || dns_name.find('\0') != std::string::npos ||
dns_name.length() == host_name.length() ||
- !IsHostNameKnownTLD(dns_name)) {
+ !HostNameHasKnownTLD(dns_name)) {
continue;
} else if (dns_name.length() > host_name.length()) {
if (url_formatter::StripWWW(base::ASCIIToUTF16(dns_name)) ==
@@ -393,7 +390,7 @@ bool IsSubDomainOutsideWildcard(const GURL& request_url,
for (const auto& dns_name : dns_names) {
if (dns_name.length() < 2 || dns_name.length() >= host_name.length() ||
dns_name.find('\0') != std::string::npos ||
- !IsHostNameKnownTLD(dns_name) || dns_name[0] != '*' ||
+ !HostNameHasKnownTLD(dns_name) || dns_name[0] != '*' ||
dns_name[1] != '.') {
continue;
}
« no previous file with comments | « components/ssl_errors/error_classification.h ('k') | components/ssl_errors/error_classification_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698