diff --git a/frontend/src/components/files/Preview.vue b/frontend/src/components/files/Preview.vue index f2c39092..2e89b92c 100644 --- a/frontend/src/components/files/Preview.vue +++ b/frontend/src/components/files/Preview.vue @@ -99,13 +99,13 @@ export default { return (this.nextLink !== '') }, download () { - return `${baseURL}/api/raw${escape(this.req.path)}?auth=${this.jwt}` + return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}` }, previewUrl () { if (this.req.type === 'image') { - return `${baseURL}/api/preview/big${escape(this.req.path)}?auth=${this.jwt}` + return `${baseURL}/api/preview/big${url.encodePath(this.req.path)}?auth=${this.jwt}` } - return `${baseURL}/api/raw${escape(this.req.path)}?auth=${this.jwt}` + return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}` }, raw () { return `${this.previewUrl}&inline=true` diff --git a/frontend/src/utils/url.js b/frontend/src/utils/url.js index 44779d3a..30e0a658 100644 --- a/frontend/src/utils/url.js +++ b/frontend/src/utils/url.js @@ -20,7 +20,12 @@ function encodeRFC5987ValueChars(str) { replace(/%(?:7C|60|5E)/g, unescape); } +function encodePath(str) { + return str.split('/').map(v => encodeURIComponent(v)).join('/') +} + export default { encodeRFC5987ValueChars: encodeRFC5987ValueChars, - removeLastDir: removeLastDir + removeLastDir: removeLastDir, + encodePath: encodePath }