Sfoglia il codice sorgente

:wrench: fixed QRImagick module value validation

smiley 2 anni fa
parent
commit
edbc995b63
2 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 1 1
      src/Output/QRImagick.php
  2. 2 0
      tests/Output/QRImagickTest.php

+ 1 - 1
src/Output/QRImagick.php

@@ -78,7 +78,7 @@ class QRImagick extends QROutputAbstract{
 		// #rrggbb(aa)
 		// #rrggbb(aa)
 		// #rrrrggggbbbb(aaaa)
 		// #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;
 			return true;
 		}
 		}
 
 

+ 2 - 0
tests/Output/QRImagickTest.php

@@ -40,10 +40,12 @@ final class QRImagickTest extends QROutputTestAbstract{
 	public static function moduleValueProvider():array{
 	public static function moduleValueProvider():array{
 		return [
 		return [
 			'invalid: wrong type'            => [[], false],
 			'invalid: wrong type'            => [[], false],
+			'valid: hex color, numeric (3)'  => ['#123', true],
 			'valid: hex color (3)'           => ['#abc', true],
 			'valid: hex color (3)'           => ['#abc', true],
 			'valid: hex color (4)'           => ['#abcd', true],
 			'valid: hex color (4)'           => ['#abcd', true],
 			'valid: hex color (6)'           => ['#aabbcc', true],
 			'valid: hex color (6)'           => ['#aabbcc', true],
 			'valid: hex color (8)'           => ['#aabbccdd', true],
 			'valid: hex color (8)'           => ['#aabbccdd', true],
+			'valid: hex color, numeric (8)'  => ['#11bb33dd', true],
 			'valid: hex color (32)'          => ['#aaaaaaaabbbbbbbbccccccccdddddddd', true],
 			'valid: hex color (32)'          => ['#aaaaaaaabbbbbbbbccccccccdddddddd', true],
 			'invalid: hex color (non-hex)'   => ['#aabbcxyz', false],
 			'invalid: hex color (non-hex)'   => ['#aabbcxyz', false],
 			'invalid: hex color (too short)' => ['#aa', false],
 			'invalid: hex color (too short)' => ['#aa', false],