From db3aa8829b380d2d5bd992b7d3594de50119b4c3 Mon Sep 17 00:00:00 2001 From: salah eddine bendyab <64494826+salahhusa9@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:00:51 +0100 Subject: [PATCH 1/2] chore: Add error handling for empty or missing response in GeetestCaptcha class --- src/GeetestCaptcha.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/GeetestCaptcha.php b/src/GeetestCaptcha.php index 862b3f9..f5793f4 100644 --- a/src/GeetestCaptcha.php +++ b/src/GeetestCaptcha.php @@ -55,6 +55,10 @@ public function validate($value) $obj = json_decode($res, true); $this->validatedData = $obj; + if (empty($obj) or !isset($obj['result'])) { + return false; + } + if ($obj['result'] != 'success') { return false; } From c43270b6e55b498eb1e228ae7fe455a186b9bfa4 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Tue, 12 Nov 2024 12:01:11 +0000 Subject: [PATCH 2/2] Fix styling --- src/GeetestCaptcha.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GeetestCaptcha.php b/src/GeetestCaptcha.php index f5793f4..2675c3c 100644 --- a/src/GeetestCaptcha.php +++ b/src/GeetestCaptcha.php @@ -55,7 +55,7 @@ public function validate($value) $obj = json_decode($res, true); $this->validatedData = $obj; - if (empty($obj) or !isset($obj['result'])) { + if (empty($obj) or ! isset($obj['result'])) { return false; }