Explorar o código

:octocat: regex fix (#282)

smiley hai 1 ano
pai
achega
f822e807d7
Modificáronse 2 ficheiros con 10 adicións e 1 borrados
  1. 1 1
      src/Data/AlphaNum.php
  2. 9 0
      tests/Data/AlphaNumTest.php

+ 1 - 1
src/Data/AlphaNum.php

@@ -36,7 +36,7 @@ final class AlphaNum extends QRDataModeAbstract{
 	}
 
 	public static function validateString(string $string):bool{
-		return (bool)preg_match('#^['.self::CHAR_MAP.']+$#', $string);
+		return (bool)preg_match('/^[A-Z\d %$*+-.:\/]+$/', $string);
 	}
 
 	public function write(BitBuffer $bitBuffer, int $versionNumber):static{

+ 9 - 0
tests/Data/AlphaNumTest.php

@@ -34,6 +34,15 @@ final class AlphaNumTest extends DataInterfaceTestAbstract{
 		return [
 			['ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:', true],
 			['abc', false],
+			['ÄÖÜ', false],
+			[',', true],
+			['-', true],
+			['+', true],
+			['.', true],
+			['*', true],
+			[':', true],
+			['/', true],
+			['\\', false],
 		];
 	}