fix bug #88: use decode_utf8_parameters()

This commit is contained in:
Dietmar Maurer 2012-01-19 14:08:49 +01:00
parent ffdb22ffc6
commit d25e743196
2 changed files with 9 additions and 9 deletions

View File

@ -237,7 +237,7 @@ my $extract_params = sub {
$params->{$k} = $query_params->{$k}; $params->{$k} = $query_params->{$k};
} }
return $params; return PVE::Tools::decode_utf8_parameters($params);
}; };
sub handle_requests { sub handle_requests {

View File

@ -69,10 +69,10 @@ sub format_response_data {
my ($ct, $raw); my ($ct, $raw);
if ($format eq 'json') { if ($format eq 'json') {
$ct = 'application/json'; $ct = 'application/json;charset=UTF-8';
$raw = to_json($data, {utf8 => 1, allow_nonref => 1}); $raw = to_json($data, {utf8 => 1, allow_nonref => 1});
} elsif ($format eq 'html') { } elsif ($format eq 'html') {
$ct = 'text/html'; $ct = 'text/html;charset=UTF-8';
$raw = "<html><body>"; $raw = "<html><body>";
if (!is_success($res->{status})) { if (!is_success($res->{status})) {
my $msg = $res->{message} || ''; my $msg = $res->{message} || '';
@ -102,7 +102,7 @@ sub format_response_data {
} }
} else { } else {
$raw .= "<pre>"; $raw .= "<pre>";
$raw .= encode_entities(to_json($data, {utf8 => 1, allow_nonref => 1, pretty => 1})); $raw .= encode_entities(to_json($data, {allow_nonref => 1, pretty => 1}));
$raw .= "</pre>"; $raw .= "</pre>";
} }
$raw .= "</body></html>"; $raw .= "</body></html>";
@ -122,14 +122,14 @@ sub format_response_data {
} }
} elsif ($format eq 'extjs') { } elsif ($format eq 'extjs') {
$ct = 'application/json'; $ct = 'application/json;charset=UTF-8';
$raw = to_json($data, {utf8 => 1, allow_nonref => 1}); $raw = to_json($data, {utf8 => 1, allow_nonref => 1});
} elsif ($format eq 'htmljs') { } elsif ($format eq 'htmljs') {
# we use this for extjs file upload forms # we use this for extjs file upload forms
$ct = 'text/html'; $ct = 'text/html;charset=UTF-8';
$raw = encode_entities(to_json($data, {utf8 => 1, allow_nonref => 1})); $raw = encode_entities(to_json($data, {allow_nonref => 1}));
} else { } else {
$ct = 'text/plain'; $ct = 'text/plain;charset=UTF-8';
$raw = to_json($data, {utf8 => 1, allow_nonref => 1, pretty => 1}); $raw = to_json($data, {utf8 => 1, allow_nonref => 1, pretty => 1});
} }
@ -462,7 +462,7 @@ sub rest_handler {
sub split_abs_uri { sub split_abs_uri {
my ($abs_uri) = @_; my ($abs_uri) = @_;
my ($format, $rel_uri) = $abs_uri =~ m/^\Q$baseuri\E\/+(html|json|extjs|png|htmljs)(\/.*)?$/; my ($format, $rel_uri) = $abs_uri =~ m/^\Q$baseuri\E\/+(html|text|json|extjs|png|htmljs)(\/.*)?$/;
$rel_uri = '/' if !$rel_uri; $rel_uri = '/' if !$rel_uri;
return wantarray ? ($rel_uri, $format) : $rel_uri; return wantarray ? ($rel_uri, $format) : $rel_uri;