Skip to content

Commit

Permalink
fix: TokenPicker crash on bad characters by whitelisting good chars (#…
Browse files Browse the repository at this point in the history
…150)

Fix TokenPicker crash on bad characters by whitelisting good chars
  • Loading branch information
dib542 authored Oct 3, 2022
1 parent 2c4e560 commit cbe1fff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/TokenPicker/TokenPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit cbe1fff

Please sign in to comment.