summaryrefslogtreecommitdiff
path: root/www/chromium-uc/patches/extra/ungoogled-chromium/add-flag-to-force-punycode-hostnames.patch
blob: be26b2c249d606162f18ca79dd62681562ae2a6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Add flag to force punycode in hostnames instead of Unicode when displaying Internationalized Domain Names (IDNs) to mitigate homograph attacks

--- chrome/browser/ungoogled_flag_entries.h.orig
+++ chrome/browser/ungoogled_flag_entries.h
@@ -24,4 +24,8 @@
      "Disable beforeunload",
      "Disables JavaScript dialog boxes triggered by beforeunload.  ungoogled-chromium flag.",
      kOsAll, SINGLE_VALUE_TYPE("disable-beforeunload")},
+    {"force-punycode-hostnames",
+     "Force punycode hostnames",
+     "Force punycode in hostnames instead of Unicode when displaying Internationalized Domain Names (IDNs).  ungoogled-chromium flag.",
+     kOsAll, SINGLE_VALUE_TYPE("force-punycode-hostnames")},
 #endif  // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_
--- components/url_formatter/url_formatter.cc.orig
+++ 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/strings/strcat.h"
@@ -264,6 +265,13 @@ IDNConversionResult IDNToUnicodeWithAdju
   host16.reserve(host.length());
   host16.insert(host16.end(), host.begin(), host.end());
 
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch("force-punycode-hostnames")) {
+    // Leave as punycode.
+    IDNConversionResult result;
+    result.result = host16;
+    return result;
+  }
+
   // Compute the top level domain to be used in spoof checks later.
   base::StringPiece top_level_domain;
   std::u16string top_level_domain_unicode;