]> git.proxmox.com Git - pve-common.git/commitdiff
new helper decode_utf8_parameters()
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 19 Jan 2012 13:01:02 +0000 (14:01 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 19 Jan 2012 13:05:19 +0000 (14:05 +0100)
Both CGI.pm and Getopt.pm does not decode utf8 strings, so we need
to do that manually.

Makefile
data/PVE/JSONSchema.pm
data/PVE/Tools.pm
debian/changelog

index a1568cf12ceac59934eab1255ab85417bfbcd2f2..4ec136bc16c011302bfc58d3033f6b94cd5b1072 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 RELEASE=2.0
 
 VERSION=1.0
-PKGREL=12
+PKGREL=13
 
 PACKAGE=libpve-common-perl
 
index 7decdb51328b61d54071e1af27f9e53c28e403b1..67aa587c6c510cb92b32015241593bf489d09a9b 100644 (file)
@@ -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') {
index 72494027a1e937b310c1fe7515d6e10f93d8d81b..dc4bbfd33f7269739dfe5ff18fe99a9098acbbdc 100644 (file)
@@ -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());
index cb556c560e7acc85deb9e6936c3ab6bdc250b57f..b19cd5aa94fa99f09f3472d1ab33375e8ae36c3f 100644 (file)
@@ -1,3 +1,9 @@
+libpve-common-perl (1.0-13) unstable; urgency=low
+
+  * correctly decode utf8 CLI parameters.
+
+ -- Proxmox Support Team <support@proxmox.com>  Thu, 19 Jan 2012 14:04:03 +0100
+
 libpve-common-perl (1.0-12) unstable; urgency=low
 
   * new helper kvmkeymaplist()