Skip to content

Commit 4388ecc

Browse files
authored
Fix sanitize file path while drag and drop (#3492)
1 parent 656d807 commit 4388ecc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

web-app/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ import TooltipWrapper from "../../../../Common/TooltipWrapper/TooltipWrapper";
122122
import ListObjectsTable from "./ListObjectsTable";
123123
import FilterObjectsSB from "../../../../ObjectBrowser/FilterObjectsSB";
124124
import AddAccessRule from "../../../BucketDetails/AddAccessRule";
125+
import { sanitizeFilePath } from "./utils";
125126

126127
const DeleteMultipleObjects = withSuspense(
127128
React.lazy(() => import("./DeleteMultipleObjects")),
@@ -506,7 +507,7 @@ const ListObjects = () => {
506507

507508
const blobFile = new Blob([file], { type: file.type });
508509

509-
const filePath = get(file, "path", "");
510+
const filePath = sanitizeFilePath(get(file, "path", ""));
510511
const fileWebkitRelativePath = get(file, "webkitRelativePath", "");
511512

512513
let relativeFolderPath = folderPath;

web-app/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/utils.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,8 @@ export const displayFileIconName = (
134134

135135
return <IconWithLabel icon={icon} strings={splitItem} />;
136136
};
137+
138+
export const sanitizeFilePath = (filePath: string) => {
139+
// Replace `./` at the start of the path or preceded by `/` - happens when drag drop upload of files (not folders !) in chrome
140+
return filePath.replace(/(^|\/)\.\//g, "/");
141+
};

0 commit comments

Comments
 (0)