]> git.proxmox.com Git - pve-common.git/blobdiff - data/PVE/Tools.pm
add 'name' to the list of utf8 encoded parameters
[pve-common.git] / data / PVE / Tools.pm
index 72494027a1e937b310c1fe7515d6e10f93d8d81b..d1dfa5d105afc36c35a9bc8f170bae347ef6a6e4 100644 (file)
@@ -417,6 +417,7 @@ sub run_command {
        }
 
        if ($errmsg) {
+           $err =~ s/^usermod:\s*// if $cmdstr =~ m|^(\S+/)?usermod\s|;
            die "$errmsg: $err";
        } else {
            die "command '$cmdstr' failed: $err";
@@ -454,6 +455,8 @@ sub trim {
 sub template_replace {
     my ($tmpl, $data) = @_;
 
+    return $tmpl if !$tmpl;
     my $res = '';
     while ($tmpl =~ m/([^{]+)?({([^}]+)})?/g) {
        $res .= $1 if $1;
@@ -547,7 +550,7 @@ my $keymaphash =  {
     'pt-br'  => ['Brazil-Portuguese', 'pt-br', 'qwerty/br-latin1.kmap.gz', 'br', 'nodeadkeys'],
     #'ru'     => ['Russian', 'ru', 'qwerty/ru.kmap.gz', 'ru', undef], # dont know?
     'si'     => ['Slovenian', 'sl', 'qwertz/slovene.kmap.gz', 'si', undef],
-    #'sv'     => [], Swedish ?
+    'se'     => ['Swedish', 'sv', 'qwerty/se-latin1.kmap.gz', 'se', 'nodeadkeys'],
     #'th'     => [],
     #'tr'     => [],
 };
@@ -727,6 +730,16 @@ sub decode_text {
     return Encode::decode("utf8", uri_unescape($data));
 }
 
+sub decode_utf8_parameters {
+    my ($param) = @_;
+
+    foreach my $p (qw(name 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());