From 815b2abaea85542a510075de84a155bda3027550 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 19 Jan 2012 14:01:02 +0100 Subject: [PATCH] new helper decode_utf8_parameters() Both CGI.pm and Getopt.pm does not decode utf8 strings, so we need to do that manually. --- Makefile | 2 +- data/PVE/JSONSchema.pm | 7 ++++++- data/PVE/Tools.pm | 10 ++++++++++ debian/changelog | 6 ++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a1568cf..4ec136b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ RELEASE=2.0 VERSION=1.0 -PKGREL=12 +PKGREL=13 PACKAGE=libpve-common-perl diff --git a/data/PVE/JSONSchema.pm b/data/PVE/JSONSchema.pm index 7decdb5..67aa587 100644 --- a/data/PVE/JSONSchema.pm +++ b/data/PVE/JSONSchema.pm @@ -914,7 +914,12 @@ sub get_options { } } } - + + $opts = PVE::Tools::decode_utf8_parameters($opts); + if ($opts->{description}) { + print "TEST: " . PVE::Tools::encode_text($opts->{description}) . "\n"; + } + foreach my $p (keys %$opts) { if (my $pd = $schema->{properties}->{$p}) { if ($pd->{type} eq 'boolean') { diff --git a/data/PVE/Tools.pm b/data/PVE/Tools.pm index 7249402..dc4bbfd 100644 --- a/data/PVE/Tools.pm +++ b/data/PVE/Tools.pm @@ -727,6 +727,16 @@ sub decode_text { return Encode::decode("utf8", uri_unescape($data)); } +sub decode_utf8_parameters { + my ($param) = @_; + + foreach my $p (qw(comment description firstname lastname)) { + $param->{$p} = decode('utf8', $param->{$p}) if $param->{$p}; + } + + return $param; +} + sub random_ether_addr { my $rand = Digest::SHA1::sha1_hex(rand(), time()); diff --git a/debian/changelog b/debian/changelog index cb556c5..b19cd5a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libpve-common-perl (1.0-13) unstable; urgency=low + + * correctly decode utf8 CLI parameters. + + -- Proxmox Support Team Thu, 19 Jan 2012 14:04:03 +0100 + libpve-common-perl (1.0-12) unstable; urgency=low * new helper kvmkeymaplist() -- 2.39.2