3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-19 10:29:30 +01: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 $@; local $@;
eval { eval {
my $h = decode_json($string); my $h = decode_json($string);
if (not defined $h) {
$string = 'null';
} else {
foreach my $k (keys %$h) { $h->{$k} = substr $h->{$k}, 0, $max_length unless $max_length <= 0; } foreach my $k (keys %$h) { $h->{$k} = substr $h->{$k}, 0, $max_length unless $max_length <= 0; }
$string = encode_json($h); $string = encode_json($h);
}
}; };
if ($@) { if ($@) {