From dd29a87107ee966df37507abdf2b5af850ceb132 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 26 Jan 2019 10:46:48 +0000 Subject: [PATCH] fix: correctly encode URIs (#85) * fix: correctly encode URIs License: MIT Signed-off-by: Henrique Dias * fix: encode uri component on copy, move and rename License: MIT Signed-off-by: Henrique Dias --- src/api/files.js | 2 +- src/components/prompts/Copy.vue | 2 +- src/components/prompts/Move.vue | 2 +- src/components/prompts/NewDir.vue | 2 +- src/components/prompts/NewFile.vue | 2 +- src/components/prompts/Rename.vue | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/files.js b/src/api/files.js index 917e46ec..971b056e 100644 --- a/src/api/files.js +++ b/src/api/files.js @@ -9,7 +9,7 @@ export async function fetch (url) { if (res.status === 200) { let data = await res.json() - data.url = `/files${data.path}` + data.url = `/files${url}` if (data.isDir) { if (!data.url.endsWith('/')) data.url += '/' diff --git a/src/components/prompts/Copy.vue b/src/components/prompts/Copy.vue index 42c262bf..91471bf4 100644 --- a/src/components/prompts/Copy.vue +++ b/src/components/prompts/Copy.vue @@ -49,7 +49,7 @@ export default { for (let item of this.selected) { items.push({ from: this.req.items[item].url, - to: this.dest + this.req.items[item].name + to: this.dest + encodeURIComponent(this.req.items[item].name) }) } diff --git a/src/components/prompts/Move.vue b/src/components/prompts/Move.vue index 4aa67931..c827ea48 100644 --- a/src/components/prompts/Move.vue +++ b/src/components/prompts/Move.vue @@ -47,7 +47,7 @@ export default { for (let item of this.selected) { items.push({ from: this.req.items[item].url, - to: this.dest + this.req.items[item].name + to: this.dest + encodeURIComponent(this.req.items[item].name) }) } diff --git a/src/components/prompts/NewDir.vue b/src/components/prompts/NewDir.vue index 27d07b30..c3dfed52 100644 --- a/src/components/prompts/NewDir.vue +++ b/src/components/prompts/NewDir.vue @@ -53,7 +53,7 @@ export default { uri = url.removeLastDir(uri) + '/' } - uri += this.name + '/' + uri += encodeURIComponent(this.name) + '/' uri = uri.replace('//', '/') try { diff --git a/src/components/prompts/NewFile.vue b/src/components/prompts/NewFile.vue index a4ccf514..5a6d5cd6 100644 --- a/src/components/prompts/NewFile.vue +++ b/src/components/prompts/NewFile.vue @@ -53,7 +53,7 @@ export default { uri = url.removeLastDir(uri) + '/' } - uri += this.name + uri += encodeURIComponent(this.name) uri = uri.replace('//', '/') try { diff --git a/src/components/prompts/Rename.vue b/src/components/prompts/Rename.vue index 2c35244e..1c130bc5 100644 --- a/src/components/prompts/Rename.vue +++ b/src/components/prompts/Rename.vue @@ -68,7 +68,7 @@ export default { oldLink = this.req.items[this.selected[0]].url } - newLink = url.removeLastDir(oldLink) + '/' + this.name + newLink = url.removeLastDir(oldLink) + '/' + encodeURIComponent(this.name) try { await api.move([{ from: oldLink, to: newLink }])