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

Unified Diff: components/url_formatter/url_formatter.cc

Issue 2784933002: Mitigate spoofing attempt using Latin letters. (Closed)
Patch Set: use checked_cast and make win64 happy Created 3 years, 7 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/url_formatter/url_formatter.cc
diff --git a/components/url_formatter/url_formatter.cc b/components/url_formatter/url_formatter.cc
index f3da52cb748435f3f75c4525550882ad9033aeaf..298b1c18ff42bfae9102433a16200dd4a65d642b 100644
--- a/components/url_formatter/url_formatter.cc
+++ b/components/url_formatter/url_formatter.cc
@@ -212,6 +212,7 @@ base::string16 IDNToUnicodeWithAdjustments(
// Do each component of the host separately, since we enforce script matching
// on a per-component basis.
base::string16 out16;
+ bool has_idn_component = false;
for (size_t component_start = 0, component_end;
component_start < input16.length();
component_start = component_end + 1) {
@@ -227,6 +228,7 @@ base::string16 IDNToUnicodeWithAdjustments(
converted_idn =
IDNToUnicodeOneComponent(input16.data() + component_start,
component_length, is_tld_ascii, &out16);
+ has_idn_component |= converted_idn;
}
size_t new_component_length = out16.length() - new_component_start;
@@ -239,6 +241,15 @@ base::string16 IDNToUnicodeWithAdjustments(
if (component_end < input16.length())
out16.push_back('.');
}
+
+ // Leave as punycode any inputs that spoof top domains.
+ if (has_idn_component &&
+ g_idn_spoof_checker.Get().SimilarToTopDomains(out16)) {
+ if (adjustments)
+ adjustments->clear();
+ return input16;
+ }
+
return out16;
}
« no previous file with comments | « components/url_formatter/top_domains/make_top_domain_gperf.cc ('k') | components/url_formatter/url_formatter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698