mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
Avoid die while decoding erroneus json data
This commit is contained in:
parent
454e6120e4
commit
d160737fb2
@ -2462,12 +2462,20 @@ sub p_decode_json {
|
||||
my ($pa_config, $data) = @_;
|
||||
my $decoded_data;
|
||||
|
||||
if ($JSON::VERSION > 2.90) {
|
||||
# Initialize JSON manager.
|
||||
my $json = JSON->new->utf8->allow_nonref;
|
||||
$decoded_data = $json->decode($data);
|
||||
} else {
|
||||
$decoded_data = decode_json($data);
|
||||
eval {
|
||||
local $SIG{__DIE__};
|
||||
if ($JSON::VERSION > 2.90) {
|
||||
# Initialize JSON manager.
|
||||
my $json = JSON->new->utf8->allow_nonref;
|
||||
$decoded_data = $json->decode($data);
|
||||
} 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