123456789101112131415161718192021222324252627282930313233343536373839 |
- # Add flag to force punycode in hostnames instead of Unicode when displaying Internationalized Domain Names (IDNs) to mitigate homograph attacks
- --- a/chrome/browser/about_flags.cc
- +++ b/chrome/browser/about_flags.cc
- @@ -1215,6 +1215,10 @@ const FeatureEntry kFeatureEntries[] = {
- "Disable search engine collection",
- "Prevents search engines from being added automatically.",
- kOsAll, SINGLE_VALUE_TYPE("disable-search-engine-collection")},
- + {"force-punycode-hostnames",
- + "Force punycode hostnames",
- + "Force punycode in hostnames instead of Unicode when displaying Internationalized Domain Names (IDNs).",
- + kOsAll, SINGLE_VALUE_TYPE("force-punycode-hostnames")},
- {"ignore-gpu-blacklist", flag_descriptions::kIgnoreGpuBlacklistName,
- flag_descriptions::kIgnoreGpuBlacklistDescription, kOsAll,
- SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)},
- --- a/components/url_formatter/url_formatter.cc
- +++ b/components/url_formatter/url_formatter.cc
- @@ -8,6 +8,7 @@
- #include <utility>
- #include <vector>
-
- +#include "base/command_line.h"
- #include "base/lazy_instance.h"
- #include "base/numerics/safe_conversions.h"
- #include "base/stl_util.h"
- @@ -245,6 +246,13 @@ IDNConversionResult IDNToUnicodeWithAdju
- input16.reserve(host.length());
- input16.insert(input16.end(), host.begin(), host.end());
-
- + if (base::CommandLine::ForCurrentProcess()->HasSwitch("force-punycode-hostnames")) {
- + // Leave as punycode.
- + IDNConversionResult result;
- + result.result = input16;
- + return result;
- + }
- +
- bool is_tld_ascii = true;
- size_t last_dot = host.rfind('.');
- if (last_dot != base::StringPiece::npos &&
|