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

Unified Diff: components/url_formatter/elide_url.cc

Issue 1861213002: Convert host names in ACE to Unicode in ElideHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ace => puny; comment added Created 4 years, 8 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 | « no previous file | components/url_formatter/elide_url_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/url_formatter/elide_url.cc
diff --git a/components/url_formatter/elide_url.cc b/components/url_formatter/elide_url.cc
index bcc8840c83224827b048b0638632b6e214b47d08..6e164f94508b1a9a06687f8c6372be00cf2c31b6 100644
--- a/components/url_formatter/elide_url.cc
+++ b/components/url_formatter/elide_url.cc
@@ -78,15 +78,17 @@ void SplitHost(const GURL& url,
base::string16* url_host,
base::string16* url_domain,
base::string16* url_subdomain) {
- // Get Host.
- *url_host = base::UTF8ToUTF16(url.host());
+ // GURL stores IDN hostnames in punycode. Convert back to Unicode for
+ // display to the user. (IDNToUnicode() will only perform this conversion
+ // if it's safe to display this host/domain in Unicode.)
+ *url_host = url_formatter::IDNToUnicode(url.host());
// Get domain and registry information from the URL.
- *url_domain =
- base::UTF8ToUTF16(net::registry_controlled_domains::GetDomainAndRegistry(
- url, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES));
- if (url_domain->empty())
- *url_domain = *url_host;
+ std::string domain_puny =
+ net::registry_controlled_domains::GetDomainAndRegistry(
+ url, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
+ *url_domain = domain_puny.empty() ?
+ *url_host : url_formatter::IDNToUnicode(domain_puny);
// Add port if required.
if (!url.port().empty()) {
« no previous file with comments | « no previous file | components/url_formatter/elide_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698