From cbe1fffb3fba6a41df0d648902c2335697766e25 Mon Sep 17 00:00:00 2001 From: David Uhlmann Date: Tue, 4 Oct 2022 06:20:27 +1000 Subject: [PATCH] fix: TokenPicker crash on bad characters by whitelisting good chars (#150) Fix TokenPicker crash on bad characters by whitelisting good chars --- src/components/TokenPicker/TokenPicker.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/TokenPicker/TokenPicker.tsx b/src/components/TokenPicker/TokenPicker.tsx index 49304eee3..0b7a1a182 100644 --- a/src/components/TokenPicker/TokenPicker.tsx +++ b/src/components/TokenPicker/TokenPicker.tsx @@ -188,9 +188,9 @@ export default function TokenPicker({ const queryRegexText = searchQuery .trim() .toLowerCase() - .replace(/[.*\\{}[\]+$^]/gi, (char) => `\\${char}`) - .replace(/\s+/g, '\\s*') - .replace(/^["'](.*)["']$/, '$1'); // remove quotes + .replace(/\s+/g, ' ') //condense spaces + .replace(/^["']*(.*)["']*$/, '$1') // remove enclosing quotes + .replace(/[^a-z0-9 ]/gi, (char) => `\\${char}`); // whitelist ok chars const regexQuery = new RegExp(`(${queryRegexText})`, 'i'); setFilteredList(