From fb67614eac0762ae04172fb26929c090b738e58a Mon Sep 17 00:00:00 2001 From: Igor-Tkachenko Date: Thu, 1 Jun 2023 19:00:46 +0300 Subject: [PATCH 1/2] fixed amount value check --- src/GiftAidField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GiftAidField.php b/src/GiftAidField.php index fadc234..c152b7e 100644 --- a/src/GiftAidField.php +++ b/src/GiftAidField.php @@ -118,7 +118,7 @@ public function get_calculated_gift(): string // phpcs:ignore Generic.Files.LineLength.TooLong $calculationText = 'With Gift Aid, your donation of {{ donation }} would be worth {{ calculated_gift_aid }} at no extra cost to you.'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $donation = (isset($_GET['amount']) ? sanitize_text_field(wp_unslash($_GET['amount'])) : 0); + $donation = (! empty($_GET['amount']) ? (int) sanitize_text_field(wp_unslash($_GET['amount'])) : 0); $amount = ($donation * 25) / 100; $totalAmt = $donation + $amount; $displayNum = number_format((float) $totalAmt, 2, '.', ''); From a61db4cebd9135172c655569b0828b83130cc3e8 Mon Sep 17 00:00:00 2001 From: Igor-Tkachenko Date: Fri, 2 Jun 2023 11:29:57 +0300 Subject: [PATCH 2/2] code review fix --- src/GiftAidField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GiftAidField.php b/src/GiftAidField.php index c152b7e..e226599 100644 --- a/src/GiftAidField.php +++ b/src/GiftAidField.php @@ -118,7 +118,7 @@ public function get_calculated_gift(): string // phpcs:ignore Generic.Files.LineLength.TooLong $calculationText = 'With Gift Aid, your donation of {{ donation }} would be worth {{ calculated_gift_aid }} at no extra cost to you.'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $donation = (! empty($_GET['amount']) ? (int) sanitize_text_field(wp_unslash($_GET['amount'])) : 0); + $donation = absint($_GET['amount'] ?? 0); $amount = ($donation * 25) / 100; $totalAmt = $donation + $amount; $displayNum = number_format((float) $totalAmt, 2, '.', '');