]> cat aescling's git repositories - mastodon.git/commitdiff
Perform case-insensitive comparison for international domain names
authorThibaut Girka <thib@sitedethib.com>
Thu, 1 Aug 2019 16:13:08 +0000 (18:13 +0200)
committerThibG <thib@sitedethib.com>
Sun, 4 Aug 2019 20:25:56 +0000 (22:25 +0200)
Note: this uses `toLowerCase()` instead of doing proper case folding

app/javascript/flavours/glitch/components/status_content.js

index e51cc8fd56c520266030a1cef9245d7c6b8b031d..147c1d1b19cf49409549b61668c03192ad10e79e 100644 (file)
@@ -65,10 +65,11 @@ const isLinkMisleading = (link, checkUrlLike = true) => {
   }
 
   // The link hasn't been recognized, maybe it features an international domain name
-  const hostname = decodeIDNA(targetURL.hostname);
+  const hostname = decodeIDNA(targetURL.hostname).normalize('NFKC');
   const host = targetURL.host.replace(targetURL.hostname, hostname);
   const origin = targetURL.origin.replace(targetURL.host, host);
-  if (textMatchesTarget(linkText, origin, host)) {
+  const text = linkText.normalize('NFKC');
+  if (textMatchesTarget(text, origin, host) || textMatchesTarget(text.toLowerCase(), origin, host)) {
     return false;
   }