From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 33F7C1FF38E for ; Tue, 28 May 2024 13:10:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 00A91154C7; Tue, 28 May 2024 13:10:38 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 28 May 2024 13:10:02 +0200 Message-Id: <20240528111002.2655756-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.021 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [tools.pm] Subject: [pve-devel] [PATCH common] fix #5486: tools: encode_text: add '%' to list of encoded characters 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: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" all text that is going through encode_text will at a later point be decoded by 'decode_text'. The latter is decoding all percent encoded characters, even those not originally encoded by 'encode_text'. This means, to preserve the original data, we first have to at least percent encode the '%' itself, otherwise it's impossible to properly store e.g. '%20' there. It would get saved as '%20' directly, but on the next read, it gets decoded to ' ', which is not the original data. instead we have to save it as '%2520', which gets then correctly decoded to '%20' again This is especially important for the vm/ct/node description, as there users can store external links, which already include percent encoded characters. Signed-off-by: Dominik Csapak --- AFAICS, we only use this for comment fields + first/lastname in access-control, so we should be ok here src/PVE/Tools.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index 766c809..59cc5c9 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -1246,8 +1246,8 @@ sub upid_normalize_status_type { sub encode_text { my ($text) = @_; - # all control and hi-bit characters, and ':' - my $unsafe = "^\x20-\x39\x3b-\x7e"; + # all control and hi-bit characters, ':' and '%' + my $unsafe = "^\x20-\x24\x26-\x39\x3b-\x7e"; return uri_escape(Encode::encode("utf8", $text), $unsafe); } -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel