Skip to content

Commit 2fd25dc

Browse files
committed
фикс бага #67 + улучшение ёЁ
1 parent 09ea1da commit 2fd25dc

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

js/init.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,17 @@ function create_chat_connection(channel_name = '') {
8181
return;
8282
}
8383

84-
// prevent xss attack from message
85-
message = message.replace(/[^a-zA-Zа-яА-ЯёЁ0-9]/g, '');
86-
if (message.length < 2) return;
84+
// Приводим ЛЕД и ЛЁД к одному виду
85+
message = message.replace(/ё/gi, 'е');
86+
87+
// prevent xss attack
88+
// числа убираем тоже, потому что апишка контекстно зачем-то считает валидными+однинаковыми и слово СТОЛ и СТОЛ12345 (бредик да)
89+
message = message.replace(/[^a-zA-Zа-яА-Я]/g, '');
8790

88-
message = message.replace(/ё/g, 'е');
91+
// а можно вот так, останутся любые буквы любого языка. задел на мультиязычную версию.
92+
// message = message.replace(/[^\p{L}]/gu, '');
93+
94+
if (message.length < 2) return;
8995

9096
words_count++;
9197
if (words_count === 1) {

0 commit comments

Comments
 (0)