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

Unified Diff: components/url_formatter/url_fixer.cc

Issue 2433583002: Reduce buggy usage of the registry controlled domain service. (Closed)
Patch Set: Review comments 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
« no previous file with comments | « components/ssl_errors/error_classification_unittest.cc ('k') | content/renderer/webpublicsuffixlist_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/url_formatter/url_fixer.cc
diff --git a/components/url_formatter/url_fixer.cc b/components/url_formatter/url_fixer.cc
index c49b31ba08cb4ee680a9498c64abbd69c728f9d6..4335b3955de9b903f858dd5cd11e411f7d21ff4f 100644
--- a/components/url_formatter/url_fixer.cc
+++ b/components/url_formatter/url_fixer.cc
@@ -201,20 +201,15 @@ void AddDesiredTLD(const std::string& desired_tld, std::string* domain) {
if (desired_tld.empty() || domain->empty())
return;
- // Check the TLD. If the return value is positive, we already have a TLD, so
- // abort. If the return value is std::string::npos, there's no valid host,
- // but we can try to append a TLD anyway, since the host may become valid once
- // the TLD is attached -- for example, "999999999999" is detected as a broken
- // IP address and marked invalid, but attaching ".com" makes it legal. When
- // the return value is 0, there's a valid host with no known TLD, so we can
- // definitely append the user's TLD. We disallow unknown registries here so
- // users can input "mail.yahoo" and hit ctrl-enter to get
- // "www.mail.yahoo.com".
- const size_t registry_length =
- net::registry_controlled_domains::GetRegistryLength(
+ // Abort if we already have a known TLD. In the case of an invalid host,
+ // HostHasRegistryControlledDomain will return false and we will try to
+ // append a TLD (which may make it valid). For example, "999999999999" is
+ // detected as a broken IP address and marked invalid, but attaching ".com"
+ // makes it legal. We disallow unknown registries here so users can input
+ // "mail.yahoo" and hit ctrl-enter to get "www.mail.yahoo.com".
+ if (net::registry_controlled_domains::HostHasRegistryControlledDomain(
*domain, net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
- net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
- if ((registry_length != 0) && (registry_length != std::string::npos))
+ net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES))
return;
// Add the suffix at the end of the domain.
« no previous file with comments | « components/ssl_errors/error_classification_unittest.cc ('k') | content/renderer/webpublicsuffixlist_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698