From a5d9883f280103f23e4327c68779cf1cbe3150c0 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 23 Jul 2021 13:29:50 +0100 Subject: [PATCH] Updating internal search to disable features were required. --- .../src/api/controllers/row/internalSearch.js | 15 +++++---------- packages/server/src/middleware/currentapp.js | 7 ++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index 148ba3806f..11d729051c 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -22,7 +22,7 @@ const preprocess = ( } // Escape characters - if (options.escape) { + if (options.escape && originalType === "string") { value = `${value}`.replace(/[ #+\-&|!(){}\]^"~*?:\\]/g, "\\$&") } @@ -136,7 +136,8 @@ class QueryBuilder { function build(structure, queryFn) { for (let [key, value] of Object.entries(structure)) { key = preprocess(key.replace(/ /, "_"), { - escape: true, + wrap: false, + lowercase: false, }) const expression = queryFn(key, value) if (expression == null) { @@ -152,10 +153,7 @@ class QueryBuilder { if (!value) { return null } - value = preprocess(value, { - escape: true, - lowercase: true, - }) + value = preprocess(value) return `${key}:${value}*` }) } @@ -180,10 +178,7 @@ class QueryBuilder { if (!value) { return null } - value = preprocess(value, { - escape: true, - lowercase: true, - }) + value = preprocess(value) return `${key}:${value}~` }) } diff --git a/packages/server/src/middleware/currentapp.js b/packages/server/src/middleware/currentapp.js index 0e9591456c..bf043f67b3 100644 --- a/packages/server/src/middleware/currentapp.js +++ b/packages/server/src/middleware/currentapp.js @@ -12,7 +12,12 @@ module.exports = async (ctx, next) => { // try to get the appID from the request const requestAppId = getAppId(ctx) // get app cookie if it exists - const appCookie = getCookie(ctx, Cookies.CurrentApp) + let appCookie = null + try { + appCookie = getCookie(ctx, Cookies.CurrentApp) + } catch (err) { + clearCookie(ctx, Cookies.CurrentApp) + } if (!appCookie && !requestAppId) { return next() }