From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 85527D767 for ; Thu, 1 Dec 2022 13:50:38 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 652F7293C1 for ; Thu, 1 Dec 2022 13:50:38 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 1 Dec 2022 13:50:37 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 44623424B7 for ; Thu, 1 Dec 2022 13:50:37 +0100 (CET) From: Daniel Tschlatscher To: pve-devel@lists.proxmox.com Date: Thu, 1 Dec 2022 13:50:13 +0100 Message-Id: <20221201125014.359413-3-d.tschlatscher@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221201125014.359413-1-d.tschlatscher@proxmox.com> References: <20221201125014.359413-1-d.tschlatscher@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.120 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [chromium.org, hiddenelement.target, atag.download, hiddenelement.download] Subject: [pve-devel] [PATCH widget-toolkit v5 2/3] Source file download in new Utils function X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Dec 2022 12:50:38 -0000 Adds a function for downloading a file from a remote URL in the Utils class and uses it to revise one similar usage in FileBrowser.js Signed-off-by: Daniel Tschlatscher --- No changes from v4 (was last included in v2) src/Utils.js | 13 +++++++++++++ src/window/FileBrowser.js | 11 +++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Utils.js b/src/Utils.js index 7255e3f..ef0c2b8 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -1360,6 +1360,19 @@ utilities: { } return `${string}`; }, + + // Setting filename here when downloading from a remote url sometimes fails in chromium browsers + // because of a bug when using attribute download in conjunction with a self signed certificate. + // For more info see https://bugs.chromium.org/p/chromium/issues/detail?id=993362 + downloadAsFile: function(source, fileName) { + let hiddenElement = document.createElement('a'); + hiddenElement.href = source; + hiddenElement.target = '_blank'; + if (fileName) { + hiddenElement.download = fileName; + } + hiddenElement.click(); + }, }, singleton: true, diff --git a/src/window/FileBrowser.js b/src/window/FileBrowser.js index a519d6b..4e4c639 100644 --- a/src/window/FileBrowser.js +++ b/src/window/FileBrowser.js @@ -101,18 +101,17 @@ Ext.define("Proxmox.window.FileBrowser", { let params = { ...view.extraParams }; params.filepath = data.filepath; - let atag = document.createElement('a'); - atag.download = view.downloadPrefix + data.text; + let filename = view.downloadPrefix + data.text; if (data.type === 'd') { if (tar) { params.tar = 1; - atag.download += ".tar.zst"; + filename += ".tar.zst"; } else { - atag.download += ".zip"; + filename += ".zip"; } } - atag.href = me.buildUrl(view.downloadURL, params); - atag.click(); + + Proxmox.Utils.downloadAsFile(me.buildUrl(view.downloadURL, params), filename); }, fileChanged: function() { -- 2.30.2