A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: wrap query with invalid symbols in quotes
Abdullah Attaf6d1f5890aaf
diff --git a/packages/core/src/utils/query-transformer.ts b/packages/core/src/utils/query-transformer.tsindex 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}"`;}