Convert messages to Unicode NFKC in filter (#5905)

This commit is contained in:
Ben Davies
2019-10-21 07:17:49 -03:00
committed by Guangcong Luo
parent 8760b8526f
commit 21ce0229f4

View File

@@ -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, '');