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

Unified Diff: components/ssl_errors/error_classification.cc

Issue 2454553002: Revert of Reduce buggy usage of the registry controlled domain service. (Closed)
Patch Set: 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 572b5729528089c583738fe485b8f51de6e4c999..c61b3262aca91ceeb9df8e5f83ba5a1fa6e209a4 100644
--- a/components/ssl_errors/error_classification.cc
+++ b/components/ssl_errors/error_classification.cc
@@ -73,7 +73,7 @@
for (const auto& dns_name : dns_names) {
HostnameTokens dns_name_token_single;
if (dns_name.empty() || dns_name.find('\0') != std::string::npos ||
- !(HostNameHasKnownTLD(dns_name))) {
+ !(IsHostNameKnownTLD(dns_name))) {
dns_name_token_single.push_back(std::string());
} else {
dns_name_token_single = Tokenize(dns_name);
@@ -148,7 +148,7 @@
}
case ssl_errors::ErrorInfo::CERT_COMMON_NAME_INVALID: {
std::string host_name = request_url.host();
- if (HostNameHasKnownTLD(host_name)) {
+ if (IsHostNameKnownTLD(host_name)) {
HostnameTokens host_name_tokens = Tokenize(host_name);
if (IsWWWSubDomainMatch(request_url, cert))
RecordSSLInterstitialCause(overridable, WWW_SUBDOMAIN_MATCH);
@@ -278,10 +278,13 @@
g_testing_build_time.Get() = testing_time;
}
-bool HostNameHasKnownTLD(const std::string& host_name) {
- return net::registry_controlled_domains::HostHasRegistryControlledDomain(
+bool IsHostNameKnownTLD(const std::string& host_name) {
+ size_t tld_length = net::registry_controlled_domains::GetRegistryLength(
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) {
@@ -294,12 +297,12 @@
std::string* www_match_host_name) {
const std::string& host_name = request_url.host();
- if (HostNameHasKnownTLD(host_name)) {
+ if (IsHostNameKnownTLD(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() ||
- !HostNameHasKnownTLD(dns_name)) {
+ !IsHostNameKnownTLD(dns_name)) {
continue;
} else if (dns_name.length() > host_name.length()) {
if (url_formatter::StripWWW(base::ASCIIToUTF16(dns_name)) ==
@@ -390,7 +393,7 @@
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 ||
- !HostNameHasKnownTLD(dns_name) || dns_name[0] != '*' ||
+ !IsHostNameKnownTLD(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