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 <me@dualfroz.com>
This commit is contained in:
1 parent
2ad66a1cb4
commit
dccc97a0ea
2 files changed
+3
-1
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user