From f6d1f5890aafce657343ade1a9ca1483d1273bb5 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Fri, 2 May 2025 10:47:58 +0500 Subject: [PATCH] core: wrap query with invalid symbols in quotes --- packages/core/src/utils/query-transformer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/utils/query-transformer.ts b/packages/core/src/utils/query-transformer.ts index 82a28ce30..c37fdd2c3 100644 --- a/packages/core/src/utils/query-transformer.ts +++ b/packages/core/src/utils/query-transformer.ts @@ -33,20 +33,20 @@ type OperatorNode = { type: "AND" | "OR" | "NOT"; }; -const INVALID_CHARS = /[:<>./\\()$&=#!\-+~§@^?,;'"[\]{}|]/; +const INVALID_QUERY_REGEX = /[!"#$%&'()*+,\-./:;<>=?@[\\\]^_`{|}~§]/; function escapeSQLString(str: string): string { if (str.startsWith('"') && str.endsWith('"')) { const innerStr = str.slice(1, -1).replace(/"/g, '""'); return `"${innerStr}"`; } - const isInvalidChar = INVALID_CHARS.test(str); + const hasInvalidSymbol = INVALID_QUERY_REGEX.test(str); const isWildcard = str.startsWith("*") || str.endsWith("*") || str.startsWith("%") || str.endsWith("%"); - if (isInvalidChar || isWildcard) { + if (hasInvalidSymbol || isWildcard) { return `"${str}"`; }