mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 19:22:40 +01:00
Fix "null" argument converting to "{}"
This commit is contained in:
parent
53da187acc
commit
c305a9aa5b
@ -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 ($@) {
|
||||
|
Loading…
Reference in New Issue
Block a user