mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 11:43:31 +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);
|
blacklistRegexExpressions.push(expr);
|
||||||
} else {
|
} else {
|
||||||
// Lazy init
|
|
||||||
if (!blacklistWords) {
|
|
||||||
blacklistWords = [];
|
|
||||||
}
|
|
||||||
// We're not going to let regex characters fuck up our RegEx operation.
|
// We're not going to let regex characters fuck up our RegEx operation.
|
||||||
line = line.replace(regexEscapeCharacters, '\\$&');
|
line = line.replace(regexEscapeCharacters, '\\$&');
|
||||||
|
|
||||||
blacklistWords.push('^\\s*' + line);
|
blacklistRegexExpressions.push('^' + line);
|
||||||
blacklistWords.push('^\\[\\d+:\\d+\\]\\s*' + line);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const regexStrBL = blacklistWords.join('|');
|
const regexStrBL = blacklistRegexExpressions.join('|');
|
||||||
const flagsBL = 'i';
|
const flagsBL = 'i';
|
||||||
// We wrap this in a try-catch to ensure that broken regex doesn't break
|
// We wrap this in a try-catch to ensure that broken regex doesn't break
|
||||||
// the entire chat.
|
// the entire chat.
|
||||||
@@ -665,11 +660,16 @@ class ChatRenderer {
|
|||||||
// Highlight text
|
// Highlight text
|
||||||
if (!message.avoidHighlighting && this.highlightParsers) {
|
if (!message.avoidHighlighting && this.highlightParsers) {
|
||||||
this.highlightParsers.map((parser) => {
|
this.highlightParsers.map((parser) => {
|
||||||
|
const ourUser = node.getElementsByClassName('name');
|
||||||
|
const isEmote = node.getElementsByClassName('emote');
|
||||||
if (
|
if (
|
||||||
!(
|
!(
|
||||||
parser.highlightBlacklist &&
|
parser.highlightBlacklist &&
|
||||||
parser.blacklistregex &&
|
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(
|
const highlighted = highlightNode(
|
||||||
|
|||||||
Reference in New Issue
Block a user