From edbc995b6394f3a88ae54ca8e01ee84f5906533a Mon Sep 17 00:00:00 2001 From: smiley Date: Wed, 12 Jul 2023 13:17:28 +0200 Subject: [PATCH] :wrench: fixed QRImagick module value validation --- src/Output/QRImagick.php | 2 +- tests/Output/QRImagickTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Output/QRImagick.php b/src/Output/QRImagick.php index 7f3dc748b..f1e94c9e4 100644 --- a/src/Output/QRImagick.php +++ b/src/Output/QRImagick.php @@ -78,7 +78,7 @@ class QRImagick extends QROutputAbstract{ // #rrggbb(aa) // #rrrrggggbbbb(aaaa) // ... - if(preg_match('/^#[a-f]+$/i', $value) && in_array((strlen($value) - 1), [3, 4, 6, 8, 9, 12, 16, 24, 32], true)){ + if(preg_match('/^#[a-f\d]+$/i', $value) && in_array((strlen($value) - 1), [3, 4, 6, 8, 9, 12, 16, 24, 32], true)){ return true; } diff --git a/tests/Output/QRImagickTest.php b/tests/Output/QRImagickTest.php index 9f2fb7fb4..fcaf1e5e4 100644 --- a/tests/Output/QRImagickTest.php +++ b/tests/Output/QRImagickTest.php @@ -40,10 +40,12 @@ final class QRImagickTest extends QROutputTestAbstract{ public static function moduleValueProvider():array{ return [ 'invalid: wrong type' => [[], false], + 'valid: hex color, numeric (3)' => ['#123', true], 'valid: hex color (3)' => ['#abc', true], 'valid: hex color (4)' => ['#abcd', true], 'valid: hex color (6)' => ['#aabbcc', true], 'valid: hex color (8)' => ['#aabbccdd', true], + 'valid: hex color, numeric (8)' => ['#11bb33dd', true], 'valid: hex color (32)' => ['#aaaaaaaabbbbbbbbccccccccdddddddd', true], 'invalid: hex color (non-hex)' => ['#aabbcxyz', false], 'invalid: hex color (too short)' => ['#aa', false],