fix(chat): escape regexes so parentheses etc. don't bust it

This commit is contained in:
Sabe Jones
2018-11-30 16:19:22 -06:00
parent 68f420991e
commit 727041f020

View File

@@ -298,7 +298,9 @@ export default {
this.$emit('show-member-modal', memberId);
},
atHighlight (text) {
const userRegex = new RegExp(`@(${this.user.auth.local.username}|${this.user.profile.name})(?:\\b)`, 'gi');
const escapedDisplayName = escapeRegExp(this.user.profile.name);
const escapedUsername = escapeRegExp(this.user.auth.local.username);
const userRegex = new RegExp(`@(${escapedDisplayName}|${escapedUsername})(?:\\b)`, 'gi');
const atRegex = new RegExp(/(?!\b)@[\w-]+/g);
if (userRegex.test(text)) {