Skip to content

Commit

Permalink
fix: Properly encode the DAV path
Browse files Browse the repository at this point in the history
Signed-off-by: Robbert Gurdeep Singh <git@beardhatcode.be>
  • Loading branch information
beardhatcode committed Apr 20, 2021
1 parent a3d9587 commit 02e1b1a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/utils/fileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ const getDavPath = function({ filename, basename }) {
// TODO: allow proper dav access without the need of basic auth
// https://github.com/nextcloud/server/issues/19700
if (isPublic()) {
return generateUrl(`/s/${getToken()}/download?path=${dirname(filename)}&files=${basename}`)
return generateUrl(`/s/${getToken()}/download?path=${encodeURIComponent(dirname(filename))}&files=${encodeURIComponent(basename)}`)
}
return getRootPath() + filename
return getRootPath() + filename.split('/').map((x) => encodeURIComponent(x)).join('/')
}

export { encodeFilePath, extractFilePaths, sortCompare, genFileInfo, getDavPath }

0 comments on commit 02e1b1a

Please sign in to comment.