From 7c72a2bce89fb22ba061aea38d034b4437366df6 Mon Sep 17 00:00:00 2001 From: C Dharmateja Date: Wed, 1 Dec 2021 19:52:26 +0530 Subject: [PATCH] fix: safely parse input value for regex --- src/shared/components/InputSelect/index.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/components/InputSelect/index.jsx b/src/shared/components/InputSelect/index.jsx index a91c088093..98e8b5355d 100644 --- a/src/shared/components/InputSelect/index.jsx +++ b/src/shared/components/InputSelect/index.jsx @@ -139,9 +139,10 @@ export default class InputSelect extends Component { filterVal, } = this.state; + const escapeRegExp = stringToGoIntoTheRegex => stringToGoIntoTheRegex.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); let fiterList = options; if (filterVal) { - const REG = new RegExp(filterVal, 'i'); + const REG = new RegExp(escapeRegExp(filterVal), 'i'); fiterList = filter(options, o => REG.test(o[labelKey])); } const list = map(fiterList, o => (