From dccc97a0eafa24dc2d80dfb9185e68a9bce5c2b6 Mon Sep 17 00:00:00 2001 From: Michal Fox Date: Fri, 2 Oct 2026 16:25:55 +0200 Subject: [PATCH] cli formatter: decode the output of the yaml renderer 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 100644 --- 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) {