From b768a2e8cb5e58497c21f1418d704112a70725d8 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 23 Oct 2022 08:21:37 +0200 Subject: [PATCH] use JSON wrapper for decoding error catching --- lib/YourlsProxy.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/YourlsProxy.php b/lib/YourlsProxy.php index 9d4cee8..b516110 100644 --- a/lib/YourlsProxy.php +++ b/lib/YourlsProxy.php @@ -12,7 +12,9 @@ namespace PrivateBin; +use Exception; use PrivateBin\Configuration; +use PrivateBin\Json; /** * YourlsProxy @@ -74,7 +76,13 @@ class YourlsProxy return; } - $data = json_decode($data, true); + try { + $data = Json::decode($data); + } catch (Exception $e) { + $this->_error = $e->getMessage(); + return; + } + if ( !is_null($data) && array_key_exists('statusCode', $data) &&