Skip to content

Commit

Permalink
fix: correct uri encode paths in fs module (#2922)
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Song <theevansong@gmail.com>
  • Loading branch information
ferothefox authored Nov 5, 2024
1 parent 907b1f6 commit ff72c90
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/frontend/src/composables/pyroServers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@ const retryWithAuth = async (requestFn: () => Promise<any>) => {

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,
});
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
});

Expand Down

0 comments on commit ff72c90

Please sign in to comment.