Skip to content

Commit edbc995

Browse files
committed
🔧 fixed QRImagick module value validation
1 parent 94ceefc commit edbc995

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Output/QRImagick.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static function moduleValueIsValid($value):bool{
7878
// #rrggbb(aa)
7979
// #rrrrggggbbbb(aaaa)
8080
// ...
81-
if(preg_match('/^#[a-f]+$/i', $value) && in_array((strlen($value) - 1), [3, 4, 6, 8, 9, 12, 16, 24, 32], true)){
81+
if(preg_match('/^#[a-f\d]+$/i', $value) && in_array((strlen($value) - 1), [3, 4, 6, 8, 9, 12, 16, 24, 32], true)){
8282
return true;
8383
}
8484

tests/Output/QRImagickTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ protected function setUp():void{
4040
public static function moduleValueProvider():array{
4141
return [
4242
'invalid: wrong type' => [[], false],
43+
'valid: hex color, numeric (3)' => ['#123', true],
4344
'valid: hex color (3)' => ['#abc', true],
4445
'valid: hex color (4)' => ['#abcd', true],
4546
'valid: hex color (6)' => ['#aabbcc', true],
4647
'valid: hex color (8)' => ['#aabbccdd', true],
48+
'valid: hex color, numeric (8)' => ['#11bb33dd', true],
4749
'valid: hex color (32)' => ['#aaaaaaaabbbbbbbbccccccccdddddddd', true],
4850
'invalid: hex color (non-hex)' => ['#aabbcxyz', false],
4951
'invalid: hex color (too short)' => ['#aa', false],

0 commit comments

Comments
 (0)