From 15028992d66e009a79d62a6197f7b3cc2bb0a2f9 Mon Sep 17 00:00:00 2001 From: Alexander Onnikov <Alexander.Onnikov@xored.com> Date: Fri, 30 Aug 2024 22:03:17 +0700 Subject: [PATCH] fix: URI encode datalake blob id and more workspace fixes (#6449) Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> --- packages/presentation/src/collaborator.ts | 2 +- plugins/guest-resources/src/connect.ts | 2 +- plugins/text-editor-resources/src/provider/indexeddb.ts | 2 +- plugins/text-editor-resources/src/provider/utils.ts | 2 +- plugins/workbench-resources/src/connect.ts | 2 +- server/collaborator/src/extensions/authentication.ts | 2 +- server/datalake/src/client.ts | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/presentation/src/collaborator.ts b/packages/presentation/src/collaborator.ts index 0da961198cf..712a90d0b02 100644 --- a/packages/presentation/src/collaborator.ts +++ b/packages/presentation/src/collaborator.ts @@ -21,7 +21,7 @@ import presentation from './plugin' /** @public */ export function getCollaboratorClient (): CollaboratorClient { - const workspaceId = getWorkspaceId(getMetadata(presentation.metadata.Workspace) ?? '') + const workspaceId = getWorkspaceId(getMetadata(presentation.metadata.WorkspaceId) ?? '') const token = getMetadata(presentation.metadata.Token) ?? '' const collaboratorURL = getMetadata(presentation.metadata.CollaboratorUrl) ?? '' diff --git a/plugins/guest-resources/src/connect.ts b/plugins/guest-resources/src/connect.ts index 6945461802c..ff15218d26e 100644 --- a/plugins/guest-resources/src/connect.ts +++ b/plugins/guest-resources/src/connect.ts @@ -184,7 +184,7 @@ function clearMetadata (ws: string): void { delete tokens[loc.path[1]] setMetadataLocalStorage(login.metadata.LoginTokens, tokens) } - const currentWorkspace = getMetadata(presentation.metadata.Workspace) + const currentWorkspace = getMetadata(presentation.metadata.WorkspaceId) if (currentWorkspace !== undefined) { setPresentationCookie('', currentWorkspace) } diff --git a/plugins/text-editor-resources/src/provider/indexeddb.ts b/plugins/text-editor-resources/src/provider/indexeddb.ts index ce5e4858cd5..9ce1f2a0d1f 100644 --- a/plugins/text-editor-resources/src/provider/indexeddb.ts +++ b/plugins/text-editor-resources/src/provider/indexeddb.ts @@ -26,7 +26,7 @@ export class IndexeddbProvider extends IndexeddbPersistence implements Provider readonly awareness: Awareness | null = null constructor (documentId: string, doc: YDoc) { - const workspaceId: string = getMetadata(presentation.metadata.Workspace) ?? '' + const workspaceId: string = getMetadata(presentation.metadata.WorkspaceId) ?? '' const name = `${workspaceId}/${documentId}` diff --git a/plugins/text-editor-resources/src/provider/utils.ts b/plugins/text-editor-resources/src/provider/utils.ts index 803bed89800..693089ff045 100644 --- a/plugins/text-editor-resources/src/provider/utils.ts +++ b/plugins/text-editor-resources/src/provider/utils.ts @@ -31,7 +31,7 @@ import { IndexeddbProvider } from './indexeddb' import { type Provider } from './types' export function formatCollaborativeDocumentId (collaborativeDoc: CollaborativeDoc): DocumentId { - const workspace = getMetadata(presentation.metadata.Workspace) ?? '' + const workspace = getMetadata(presentation.metadata.WorkspaceId) ?? '' return formatDocumentId(workspace, collaborativeDoc) } diff --git a/plugins/workbench-resources/src/connect.ts b/plugins/workbench-resources/src/connect.ts index 60b895527b2..88d38aae52f 100644 --- a/plugins/workbench-resources/src/connect.ts +++ b/plugins/workbench-resources/src/connect.ts @@ -348,7 +348,7 @@ function clearMetadata (ws: string): void { delete tokens[loc.path[1]] setMetadataLocalStorage(login.metadata.LoginTokens, tokens) } - const currentWorkspace = getMetadata(presentation.metadata.Workspace) + const currentWorkspace = getMetadata(presentation.metadata.WorkspaceId) if (currentWorkspace !== undefined) { setPresentationCookie('', currentWorkspace) } diff --git a/server/collaborator/src/extensions/authentication.ts b/server/collaborator/src/extensions/authentication.ts index 36ce389ed30..2d7081133b9 100644 --- a/server/collaborator/src/extensions/authentication.ts +++ b/server/collaborator/src/extensions/authentication.ts @@ -46,7 +46,7 @@ export class AuthenticationExtension implements Extension { const workspaceInfo = await getWorkspaceInfo(data.token) // verify workspace url in the document matches the token - if (workspaceInfo.workspace !== workspaceId) { + if (workspaceInfo.workspaceId !== workspaceId) { throw new Error('documentName must include workspace id') } diff --git a/server/datalake/src/client.ts b/server/datalake/src/client.ts index fa9b91b2e99..f160afa964b 100644 --- a/server/datalake/src/client.ts +++ b/server/datalake/src/client.ts @@ -49,7 +49,7 @@ export class Client { constructor (private readonly endpoint: string) {} getObjectUrl (ctx: MeasureContext, workspace: WorkspaceId, objectName: string): string { - const path = `/blob/${workspace.name}/${objectName}` + const path = `/blob/${workspace.name}/${encodeURIComponent(objectName)}` return concatLink(this.endpoint, path) } @@ -91,7 +91,7 @@ export class Client { const form = new FormData() const options: FormData.AppendOptions = { - filename: objectName, + filename: encodeURIComponent(objectName), contentType: metadata.type, knownLength: metadata.size, header: {