From 21ce0229f4c19254cb6f5a0b3de8a3cd4f0c1897 Mon Sep 17 00:00:00 2001 From: Ben Davies <34197615+Kaiepi@users.noreply.github.com> Date: Mon, 21 Oct 2019 07:17:49 -0300 Subject: [PATCH] Convert messages to Unicode NFKC in filter (#5905) --- server/chat-plugins/chat-monitor.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/chat-plugins/chat-monitor.js b/server/chat-plugins/chat-monitor.js index 83516ba7aa..25f2a856f7 100644 --- a/server/chat-plugins/chat-monitor.js +++ b/server/chat-plugins/chat-monitor.js @@ -139,6 +139,12 @@ Chat.registerMonitor('evasion', { punishment: 'EVASION', label: 'Filter Evasion Detection', monitor(line, room, user, message, lcMessage, isStaff) { + // Many codepoints used in filter evasion detection can be decomposed + // into multiple codepoints that are canonically equivalent to the + // original. Perform a canonical composition on the message to detect + // when people attempt to evade by abusing this behaviour of Unicode. + lcMessage = lcMessage.normalize('NFKC'); + let [regex, word, reason] = line; // Remove spaces and obvious false positives lcMessage = lcMessage.replace(/[\s-_,.]/g, '');