From 3f98bd02152bec9604d9bb10f561e0936fed15da Mon Sep 17 00:00:00 2001 From: tudorrrrrr <60345215+tudorrrrrr@users.noreply.github.com> Date: Mon, 19 Sep 2022 07:46:26 +0100 Subject: [PATCH] use filter_var for skip config (#60) --- src/ClamavValidator/ClamavValidator.php | 2 +- tests/ClamavValidatorTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ClamavValidator/ClamavValidator.php b/src/ClamavValidator/ClamavValidator.php index c2d224f..8fd7b34 100755 --- a/src/ClamavValidator/ClamavValidator.php +++ b/src/ClamavValidator/ClamavValidator.php @@ -45,7 +45,7 @@ public function __construct( */ public function validateClamav(string $attribute, $value, array $parameters): bool { - if (true === Config::get('clamav.skip_validation')) { + if (filter_var(Config::get('clamav.skip_validation'), FILTER_VALIDATE_BOOLEAN)) { return true; } diff --git a/tests/ClamavValidatorTest.php b/tests/ClamavValidatorTest.php index 4941a1e..e23ad18 100755 --- a/tests/ClamavValidatorTest.php +++ b/tests/ClamavValidatorTest.php @@ -87,6 +87,20 @@ public function testValidatesSkipped() $this->assertTrue($validator->passes()); } + public function testValidatesSkippedForBoolValidatedConfigValues() + { + $this->setConfig(['skip' => '1']); + + $validator = new ClamavValidator( + $this->translator, + $this->clean_data, + ['file' => 'clamav'], + $this->messages + ); + + $this->assertTrue($validator->passes()); + } + public function testValidatesClean() { $this->setConfig();