From 15f2aaf950b15e15dcbae5fed8f04e3306018554 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 16 Dec 2024 16:55:38 +0100 Subject: [PATCH] Fix encodings --- packages/backend-core/src/sql/utils.ts | 4 ++++ packages/server/src/api/controllers/row/utils/utils.ts | 2 +- packages/server/src/db/utils.ts | 10 ++-------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/backend-core/src/sql/utils.ts b/packages/backend-core/src/sql/utils.ts index 14127a189f..16b352995b 100644 --- a/packages/backend-core/src/sql/utils.ts +++ b/packages/backend-core/src/sql/utils.ts @@ -70,6 +70,10 @@ export function encodeTableId(tableId: string) { } } +export function encodeViewId(viewId: string) { + return encodeURIComponent(viewId) +} + export function breakExternalTableId(tableId: string) { const parts = tableId.split(DOUBLE_SEPARATOR) let datasourceId = parts.shift() diff --git a/packages/server/src/api/controllers/row/utils/utils.ts b/packages/server/src/api/controllers/row/utils/utils.ts index baa811fe90..86986b64e8 100644 --- a/packages/server/src/api/controllers/row/utils/utils.ts +++ b/packages/server/src/api/controllers/row/utils/utils.ts @@ -66,7 +66,7 @@ export function getSourceId(ctx: Ctx): { tableId: string; viewId?: string } { if (docIds.isViewId(sourceId)) { return { tableId: utils.extractViewInfoFromID(sourceId).tableId, - viewId: sourceId, + viewId: sql.utils.encodeViewId(sourceId), } } return { tableId: sql.utils.encodeTableId(ctx.params.sourceId) } diff --git a/packages/server/src/db/utils.ts b/packages/server/src/db/utils.ts index 70c69b3c60..6c1065e847 100644 --- a/packages/server/src/db/utils.ts +++ b/packages/server/src/db/utils.ts @@ -1,10 +1,4 @@ -import { - context, - db as dbCore, - docIds, - utils, - sql, -} from "@budibase/backend-core" +import { context, db as dbCore, docIds, utils } from "@budibase/backend-core" import { DatabaseQueryOpts, Datasource, @@ -334,7 +328,7 @@ export function extractViewInfoFromID(viewId: string) { const regex = new RegExp(`^(?.+)${SEPARATOR}([^${SEPARATOR}]+)$`) const res = regex.exec(viewId) return { - tableId: sql.utils.encodeTableId(res!.groups!["tableId"]), + tableId: res!.groups!["tableId"], } }