use JSON wrapper for decoding error catching

This commit is contained in:
El RIDO 2022-10-23 08:21:37 +02:00
parent 0a2094f069
commit b768a2e8cb
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92

View file

@ -12,7 +12,9 @@
namespace PrivateBin; namespace PrivateBin;
use Exception;
use PrivateBin\Configuration; use PrivateBin\Configuration;
use PrivateBin\Json;
/** /**
* YourlsProxy * YourlsProxy
@ -74,7 +76,13 @@ class YourlsProxy
return; return;
} }
$data = json_decode($data, true); try {
$data = Json::decode($data);
} catch (Exception $e) {
$this->_error = $e->getMessage();
return;
}
if ( if (
!is_null($data) && !is_null($data) &&
array_key_exists('statusCode', $data) && array_key_exists('statusCode', $data) &&