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 5E37D75C9E for ; Fri, 15 Oct 2021 10:07:34 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4EADD259D3 for ; Fri, 15 Oct 2021 10:07:34 +0200 (CEST) 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 id 683962599B for ; Fri, 15 Oct 2021 10:07:33 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 427BC464EB for ; Fri, 15 Oct 2021 10:07:33 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Fri, 15 Oct 2021 10:07:29 +0200 Message-Id: <20211015080730.1427860-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211015080730.1427860-1-d.csapak@proxmox.com> References: <20211015080730.1427860-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.295 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 Subject: [pbs-devel] [RFC PATCH widget-toolkit 1/1] Utils: percent-decode the task status X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Oct 2021 08:07:34 -0000 we percent-encode the taskstatus in case of an error, so that we do not have control characters (especially newlines) in the task log so on showing, we decode that again Signed-off-by: Dominik Csapak --- src/Utils.js | 12 +++++++++++- src/panel/LogView.js | 6 ++++++ src/window/TaskViewer.js | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Utils.js b/src/Utils.js index c52bef2..e18a403 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -785,11 +785,21 @@ utilities: { return 'error'; }, + percent_decode_ctrl_chars: function(status) { + return status.replaceAll(/%([0-9a-f]{2})/ig, (match, val) => { + let value = parseInt(val, 16); + if (value < 32 || value === 127) { // 0x00-0x1F && 0x7F (DEL) + return String.fromCharCode(value); + } + return match; + }); + }, + format_task_status: function(status) { let parsed = Proxmox.Utils.parse_task_status(status); switch (parsed) { case 'unknown': return Proxmox.Utils.unknownText; - case 'error': return Proxmox.Utils.errorText + ': ' + status; + case 'error': return Proxmox.Utils.errorText + ': ' + Proxmox.Utils.percent_decode_ctrl_chars(status); case 'warning': return status.replace('WARNINGS', Proxmox.Utils.warningsText); case 'ok': // fall-through default: return status; diff --git a/src/panel/LogView.js b/src/panel/LogView.js index 1772737..4558772 100644 --- a/src/panel/LogView.js +++ b/src/panel/LogView.js @@ -97,6 +97,12 @@ Ext.define('Proxmox.panel.LogView', { lines[line.n - 1] = Ext.htmlEncode(line.t); }); + // if last line contains a task error + let last_line = lines[lines.length - 1]; + if (last_line.indexOf('TASK ERROR') !== -1) { + lines[lines.length - 1] = Proxmox.Utils.percent_decode_ctrl_chars(last_line); + } + lines.length = total; me.updateView(lines.join('
'), first - 1, total); me.running = false; diff --git a/src/window/TaskViewer.js b/src/window/TaskViewer.js index 996a41b..5444842 100644 --- a/src/window/TaskViewer.js +++ b/src/window/TaskViewer.js @@ -113,7 +113,7 @@ Ext.define('Proxmox.window.TaskViewer', { } let es = statgrid.getObjectValue('exitstatus'); if (es) { - return value + ': ' + es; + return value + ': ' + Proxmox.Utils.percent_decode_ctrl_chars(es); } return 'unknown'; }, -- 2.30.2