From 56d61ce6ae9af82e4e97d86f9e418b214a6b2fc5 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 18 Jan 2022 20:47:46 +0100 Subject: [PATCH] fix: ipv6 issues with encodeURI Signed-off-by: Stefan Dej --- src/components/panels/GcodefilesPanel.vue | 4 ++-- src/components/panels/HistoryListPanel.vue | 4 ++-- src/components/panels/Machine/ConfigFilesPanel.vue | 2 +- src/components/panels/StatusPanel.vue | 4 ++-- src/components/panels/Timelapse/TimelapseFilesPanel.vue | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue index 0bba25838..681ed6f29 100644 --- a/src/components/panels/GcodefilesPanel.vue +++ b/src/components/panels/GcodefilesPanel.vue @@ -925,7 +925,7 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) { ) if (thumbnail && 'relative_path' in thumbnail) { - return encodeURI(`${this.apiUrl}/server/files/${this.currentPath}/${thumbnail.relative_path}?timestamp=${item.modified.getTime()}`) + return `${this.apiUrl}/server/files/${encodeURI(this.currentPath)}/${encodeURI(thumbnail.relative_path)}?timestamp=${item.modified.getTime()}` } } @@ -937,7 +937,7 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) { const thumbnail = item.thumbnails.find(thumb => thumb.width >= thumbnailBigMin) if (thumbnail && 'relative_path' in thumbnail) { - return encodeURI(`${this.apiUrl}/server/files/${this.currentPath}/${thumbnail.relative_path}?timestamp=${item.modified.getTime()}`) + return `${this.apiUrl}/server/files/${encodeURI(this.currentPath)}/${encodeURI(thumbnail.relative_path)}?timestamp=${item.modified.getTime()}` } } diff --git a/src/components/panels/HistoryListPanel.vue b/src/components/panels/HistoryListPanel.vue index dadf9253a..70fa92f0b 100644 --- a/src/components/panels/HistoryListPanel.vue +++ b/src/components/panels/HistoryListPanel.vue @@ -596,7 +596,7 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { } if (thumbnail && 'relative_path' in thumbnail) { - return encodeURI(`${this.apiUrl}/server/files/gcodes/${relative_url+thumbnail.relative_path}?timestamp=${item.metadata.modified}`) + return `${this.apiUrl}/server/files/gcodes/${encodeURI(relative_url+thumbnail.relative_path)}?timestamp=${item.metadata.modified}` } } @@ -617,7 +617,7 @@ export default class HistoryListPanel extends Mixins(BaseMixin) { } if (thumbnail && 'relative_path' in thumbnail) - return encodeURI(`${this.apiUrl}/server/files/gcodes/${relative_url+thumbnail.relative_path}?timestamp=${item.metadata.modified}`) + return `${this.apiUrl}/server/files/gcodes/${encodeURI(relative_url+thumbnail.relative_path)}?timestamp=${item.metadata.modified}` } return false diff --git a/src/components/panels/Machine/ConfigFilesPanel.vue b/src/components/panels/Machine/ConfigFilesPanel.vue index 4f7905b15..29f66190a 100644 --- a/src/components/panels/Machine/ConfigFilesPanel.vue +++ b/src/components/panels/Machine/ConfigFilesPanel.vue @@ -657,7 +657,7 @@ export default class ConfigFilesPanel extends Mixins(BaseMixin) { downloadFile() { const filename = (this.absolutePath+'/'+this.contextMenu.item.filename) - const href = encodeURI(`${this.apiUrl}/server/files${filename}`) + const href = `${this.apiUrl}/server/files${encodeURI(filename)}` window.open(href) } diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue index 3b29cb0e4..1c30b23a4 100644 --- a/src/components/panels/StatusPanel.vue +++ b/src/components/panels/StatusPanel.vue @@ -514,7 +514,7 @@ export default class StatusPanel extends Mixins(BaseMixin) { } if (thumbnail && 'relative_path' in thumbnail) { - return encodeURI(`${this.apiUrl}/server/files/gcodes/${relative_url+thumbnail.relative_path}?timestamp=${this.current_file.modified}`) + return `${this.apiUrl}/server/files/gcodes/${encodeURI(relative_url+thumbnail.relative_path)}?timestamp=${this.current_file.modified}` } } } @@ -536,7 +536,7 @@ export default class StatusPanel extends Mixins(BaseMixin) { } if (thumbnail && 'relative_path' in thumbnail) { - return encodeURI(`${this.apiUrl}/server/files/gcodes/${relative_url+thumbnail.relative_path}?timestamp=${this.current_file.modified}`) + return `${this.apiUrl}/server/files/gcodes/${encodeURI(relative_url+thumbnail.relative_path)}?timestamp=${this.current_file.modified}` } } } diff --git a/src/components/panels/Timelapse/TimelapseFilesPanel.vue b/src/components/panels/Timelapse/TimelapseFilesPanel.vue index 8f744f681..7a3900b2b 100644 --- a/src/components/panels/Timelapse/TimelapseFilesPanel.vue +++ b/src/components/panels/Timelapse/TimelapseFilesPanel.vue @@ -443,7 +443,7 @@ export default class TimelapseFilesPanel extends Mixins(BaseMixin) { const filename = item.filename.slice(0, item.filename.lastIndexOf('.')) const preview = this.files?.find((file) => file.filename === filename+'.jpg') if (preview) { - return encodeURI(`${this.apiUrl}/server/files/${this.currentPath}/${preview.filename}?timestamp=${preview.modified.getTime()}`) + return `${this.apiUrl}/server/files/${encodeURI(this.currentPath)}/${encodeURI(preview.filename)}?timestamp=${preview.modified.getTime()}` } return ''