mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
fix(regexp): escape inputs
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import escapeRegExp from 'lodash/escapeRegExp';
|
||||
import bannedSlurs from '../bannedSlurs';
|
||||
import { getMatchesByWordArray } from '../stringUtils';
|
||||
import forbiddenUsernames from '../forbiddenUsernames';
|
||||
|
||||
const bannedSlurRegexs = bannedSlurs.map(word => new RegExp(`.*${word}.*`, 'i'));
|
||||
const bannedSlurRegexs = bannedSlurs.map(word => {
|
||||
const escapedWord = escapeRegExp(word);
|
||||
return new RegExp(`.*${escapedWord}.*`, 'i');
|
||||
});
|
||||
|
||||
export function nameContainsSlur (username) {
|
||||
for (let i = 0; i < bannedSlurRegexs.length; i += 1) {
|
||||
|
||||
Reference in New Issue
Block a user