browser: fix file uploads with '#' in the name (#11261)

When the file name or the prefix contains `#`,
whatever comes after is ingored.

This is fixed by encoding the object path using
encodeURIComponent.

Fixes #11112
master
Kanagaraj M 4 years ago committed by GitHub
parent 1a5775e2e8
commit e09196d626
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      browser/app/js/uploads/__tests__/actions.test.js
  2. 2
      browser/app/js/uploads/actions.js
  3. 92
      browser/ui-assets.go

@ -138,9 +138,10 @@ describe("Uploads actions", () => {
objects: { currentPrefix: "pre1/" } objects: { currentPrefix: "pre1/" }
}) })
store.dispatch(uploadsActions.uploadFile(file)) store.dispatch(uploadsActions.uploadFile(file))
const objectPath = encodeURIComponent("pre1/file1")
expect(open).toHaveBeenCalledWith( expect(open).toHaveBeenCalledWith(
"PUT", "PUT",
"https://localhost:8080/upload/test1/pre1/file1", "https://localhost:8080/upload/test1/" + objectPath,
true true
) )
expect(send).toHaveBeenCalledWith(file) expect(send).toHaveBeenCalledWith(file)

@ -94,7 +94,7 @@ export const uploadFile = file => {
_filePath = _filePath.substring(1) _filePath = _filePath.substring(1)
} }
const filePath = _filePath const filePath = _filePath
const objectName = `${currentPrefix}${filePath}` const objectName = encodeURIComponent(`${currentPrefix}${filePath}`)
const uploadUrl = `${ const uploadUrl = `${
window.location.origin window.location.origin
}${minioBrowserPrefix}/upload/${currentBucket}/${objectName}` }${minioBrowserPrefix}/upload/${currentBucket}/${objectName}`

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save