mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 00:34:46 +02:00
Avoid die while decoding erroneus json data
This commit is contained in:
parent
454e6120e4
commit
d160737fb2
@ -2462,6 +2462,8 @@ sub p_decode_json {
|
||||
my ($pa_config, $data) = @_;
|
||||
my $decoded_data;
|
||||
|
||||
eval {
|
||||
local $SIG{__DIE__};
|
||||
if ($JSON::VERSION > 2.90) {
|
||||
# Initialize JSON manager.
|
||||
my $json = JSON->new->utf8->allow_nonref;
|
||||
@ -2469,6 +2471,12 @@ sub p_decode_json {
|
||||
} else {
|
||||
$decoded_data = decode_json($data);
|
||||
}
|
||||
};
|
||||
if ($@){
|
||||
if (defined($data)) {
|
||||
logger($pa_config, 'Failed to decode data: '.$@, 5);
|
||||
}
|
||||
}
|
||||
|
||||
return $decoded_data;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user