From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 95F931FF0AD for ; Sun, 04 Oct 2026 16:32:21 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 630DF21655; Sun, 04 Oct 2026 16:32:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dualfroz.com; s=dkim; t=1791124325; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=6Lh7eQ0IXwBrA51ZqElxRVXiic67HRoKxta9GatsJEI=; b=L584hpPL3FPIZNwa7cAsh3mEha5vrzPo57uzFc2WZAeRg9Psb3Az4IvGAm2SbXdZigptd2 47NECupAaZmlp8RJjLViEPHigo6x7Z5p0I94UDj9B8YFXj0hwiOq2CdAct6dKVHMk97YM6 ztuf+kL1ltQqP0RtX5LxLgSYqhNQzLrTc3xsAbOZtLrjhRZIQ3Mx7m1gTVw0dIIOv0KnX8 9JBi0N3kYUllN66yccwRonr25C1ULMITeuK67J2Uo0xvXK1yGTaCSaCpb/Yqh04dZwQtBI KRjG500o5bl58Bw4hg+Dh3pyYgSdRs3Or/43ImGmGneAkhN8lGVCrphxjvdRtw== From: Michal Fox To: pve-devel@lists.proxmox.com Subject: [PATCH common 2/2] cli formatter: decode the output of the yaml renderer Date: Sun, 4 Oct 2026 14:32:02 +0000 Message-ID: <20261004143202.7-3-me@dualfroz.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261004143202.7-1-me@dualfroz.com> References: <20261004143202.7-1-me@dualfroz.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.188 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: J6WNRYRIJLRXZLHAHG6JDLDOMYP2U6VY X-Message-ID-Hash: J6WNRYRIJLRXZLHAHG6JDLDOMYP2U6VY X-MailFrom: me@dualfroz.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: YAML::XS::Dump returns UTF-8 encoded octets, but the value returned by a renderer gets encoded when the text output is printed, like any other value. So for properties using the 'yaml' renderer, for example the account details shown by 'pvenode acme account info', any non-ASCII character got encoded twice and ended up mangled. Decode the output of YAML::XS::Dump in the renderer, so it returns a character string like all other renderers, and add a test for it. Fixes: 99d0252 ("properly encode YAML via YAML::XS") Signed-off-by: Michal Fox --- src/PVE/CLIFormatter.pm | 3 ++- test/format_test.pl | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm index d93bed6..758809e 100644 --- a/src/PVE/CLIFormatter.pm +++ b/src/PVE/CLIFormatter.pm @@ -27,7 +27,8 @@ PVE::JSONSchema::register_renderer('bytes', \&PVE::Format::render_bytes); sub render_yaml { my ($value) = @_; - my $data = YAML::XS::Dump($value); + # YAML::XS returns UTF-8 encoded output, but renderers need to return text + my $data = decode('UTF-8', YAML::XS::Dump($value)); $data =~ s/^---[\n\s]//; # remove yaml marker return $data; diff --git a/test/format_test.pl b/test/format_test.pl index 8ccfd5a..2b9460d 100755 --- a/test/format_test.pl +++ b/test/format_test.pl @@ -45,6 +45,7 @@ my $render_data = [ ["bytes", 1024, undef, "1.00 KiB"], ["bytes", 1024 * 1024 * 123 + 1024 * 300, 1, "123.3 MiB"], ["bytes", 1024 * 1024 * 1024 * 1024 * 4 + 1024 * 1024 * 2048 * 8, undef, "4.02 TiB"], + ["yaml", { description => "Erkl\x{e4}rung" }, undef, "description: Erkl\x{e4}rung\n"], ]; foreach my $data (@$render_data) { -- 2.43.0