From 9a47d065b4268c5a4ee1ac8d9c67d9ef78dfe99e Mon Sep 17 00:00:00 2001 From: mihaisc Date: Thu, 14 Oct 2021 05:48:40 -0700 Subject: [PATCH] escape es reserved chars (#922) * escape es reserved chars * fix regex --- src/components/templates/Search/utils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/templates/Search/utils.ts b/src/components/templates/Search/utils.ts index 26bfb1343..657dbdd86 100644 --- a/src/components/templates/Search/utils.ts +++ b/src/components/templates/Search/utils.ts @@ -47,6 +47,10 @@ function getSortType(sortParam: string): string { return sortTerm } +export function escapeESReservedChars(text: string): string { + return text.replace(/([!*+\-=<>&|()\\[\]{}^~?:\\/"])/g, '\\$1') +} + export function getSearchQuery( chainIds: number[], text?: string, @@ -61,6 +65,7 @@ export function getSearchQuery( accessType?: string ): any { const emptySearchTerm = text === undefined || text === '' + text = escapeESReservedChars(text) let searchTerm = owner ? `(publicKey.owner:${owner})` : tags