mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
[MIRROR] fix a rare chat crash (#10749)
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
fdc0ab5387
commit
a49a3d89a4
@@ -360,18 +360,13 @@ class ChatRenderer {
|
||||
}
|
||||
blacklistRegexExpressions.push(expr);
|
||||
} else {
|
||||
// Lazy init
|
||||
if (!blacklistWords) {
|
||||
blacklistWords = [];
|
||||
}
|
||||
// We're not going to let regex characters fuck up our RegEx operation.
|
||||
line = line.replace(regexEscapeCharacters, '\\$&');
|
||||
|
||||
blacklistWords.push('^\\s*' + line);
|
||||
blacklistWords.push('^\\[\\d+:\\d+\\]\\s*' + line);
|
||||
blacklistRegexExpressions.push('^' + line);
|
||||
}
|
||||
}
|
||||
const regexStrBL = blacklistWords.join('|');
|
||||
const regexStrBL = blacklistRegexExpressions.join('|');
|
||||
const flagsBL = 'i';
|
||||
// We wrap this in a try-catch to ensure that broken regex doesn't break
|
||||
// the entire chat.
|
||||
@@ -665,11 +660,16 @@ class ChatRenderer {
|
||||
// Highlight text
|
||||
if (!message.avoidHighlighting && this.highlightParsers) {
|
||||
this.highlightParsers.map((parser) => {
|
||||
const ourUser = node.getElementsByClassName('name');
|
||||
const isEmote = node.getElementsByClassName('emote');
|
||||
if (
|
||||
!(
|
||||
parser.highlightBlacklist &&
|
||||
parser.blacklistregex &&
|
||||
parser.blacklistregex.test(node.textContent)
|
||||
((ourUser.length > 0 &&
|
||||
parser.blacklistregex.test(ourUser[0].textContent)) ||
|
||||
(isEmote.length > 0 &&
|
||||
parser.blacklistregex.test(isEmote[0].textContent)))
|
||||
)
|
||||
) {
|
||||
const highlighted = highlightNode(
|
||||
|
||||
Reference in New Issue
Block a user