3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

Fix "null" argument converting to "{}"

This commit is contained in:
Pragmatic Software 2020-06-28 20:28:54 -07:00
parent 53da187acc
commit c305a9aa5b

View File

@ -20,8 +20,13 @@ sub validate_string {
local $@;
eval {
my $h = decode_json($string);
foreach my $k (keys %$h) { $h->{$k} = substr $h->{$k}, 0, $max_length unless $max_length <= 0; }
$string = encode_json($h);
if (not defined $h) {
$string = 'null';
} else {
foreach my $k (keys %$h) { $h->{$k} = substr $h->{$k}, 0, $max_length unless $max_length <= 0; }
$string = encode_json($h);
}
};
if ($@) {