From ff72c906ba7180ce5a9da4550bc33284599fc809 Mon Sep 17 00:00:00 2001 From: Evan Song <52982404+ferothefox@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:35:43 -0700 Subject: [PATCH] fix: correct uri encode paths in fs module (#2922) Signed-off-by: Evan Song --- apps/frontend/src/composables/pyroServers.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/frontend/src/composables/pyroServers.ts b/apps/frontend/src/composables/pyroServers.ts index d4c956536..811ca15d7 100644 --- a/apps/frontend/src/composables/pyroServers.ts +++ b/apps/frontend/src/composables/pyroServers.ts @@ -703,7 +703,8 @@ const retryWithAuth = async (requestFn: () => Promise) => { const listDirContents = (path: string, page: number, pageSize: number) => { return retryWithAuth(async () => { - return await PyroFetch(`/list?path=${path}&page=${page}&page_size=${pageSize}`, { + const encodedPath = encodeURIComponent(path); + return await PyroFetch(`/list?path=${encodedPath}&page=${page}&page_size=${pageSize}`, { override: internalServerRefrence.value.fs.auth, retry: false, }); @@ -712,7 +713,8 @@ const listDirContents = (path: string, page: number, pageSize: number) => { const createFileOrFolder = (path: string, type: "file" | "directory") => { return retryWithAuth(async () => { - return await PyroFetch(`/create?path=${path}&type=${type}`, { + const encodedPath = encodeURIComponent(path); + return await PyroFetch(`/create?path=${encodedPath}&type=${type}`, { method: "POST", contentType: "application/octet-stream", override: internalServerRefrence.value.fs.auth, @@ -722,7 +724,8 @@ const createFileOrFolder = (path: string, type: "file" | "directory") => { const uploadFile = (path: string, file: File) => { return retryWithAuth(async () => { - return await PyroFetch(`/create?path=${path}&type=file`, { + const encodedPath = encodeURIComponent(path); + return await PyroFetch(`/create?path=${encodedPath}&type=file`, { method: "POST", contentType: "application/octet-stream", body: file, @@ -803,7 +806,8 @@ const deleteFileOrFolder = (path: string, recursive: boolean) => { const downloadFile = (path: string, raw?: boolean) => { return retryWithAuth(async () => { - const fileData = await PyroFetch(`/download?path=${path}`, { + const encodedPath = encodeURIComponent(path); + const fileData = await PyroFetch(`/download?path=${encodedPath}`, { override: internalServerRefrence.value.fs.auth, });