From bcf698074bcd4efb0f68ddbc8e0f221a0075d301 Mon Sep 17 00:00:00 2001 From: luca0N! Date: Sat, 2 Jan 2021 23:57:43 -0300 Subject: [PATCH] =?UTF-8?q?Verifica=C3=A7=C3=A3o=20de=20termos=20enviados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit O servidor agora não irá permitir o envio de termos com caracteres que não sejam permitidos e, caso o filtro de temas adultos da sala esteja habilitado, irá proibir palavras filtradas também. --- index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/index.js b/index.js index 8fad2b6..3dad916 100644 --- a/index.js +++ b/index.js @@ -324,6 +324,19 @@ wss.on('connection', ws => { break; } + // Verificar termo via expressão regular. + let palavraRegexIlegal = new RegExp(vars["palavra.regex.caracteresIlegais"], 'g'); + if (palavraRegexIlegal.test(resposta.extra.termo)){ + ws.send(JSON.stringify(new Resposta("PEDIDO_CANCELADO", "SERVIDOR", "PALAVRA_OU_LETRA_PROIBIDO", { erroDescrição: "TERMO_CARACTERES_ILEGAIS" }))); + break; + } + + // Verificar se o termo enviado possui termos filtrados CASO a sala tinha o filtro habilitado + if (salaObj.opções["filtro.temasAdultos.habilitado"] && Util.filtrarMensagem(resposta.extra.termo, filtros) !== resposta.extra.termo){ + ws.send(JSON.stringify(new Resposta("PEDIDO_CANCELADO", "SERVIDOR", "PALAVRA_OU_LETRA_PROIBIDO", { erroDescrição: "TERMO_IMPRÓPRIO" }))); + break; + } + // Verificar o tipo do termo enviado. let letra = resposta.extra.termo.length === 1; let salaClientes = salaObj.clientes;