Skip to content

Commit

Permalink
:octocat: regex fix (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Oct 16, 2024
1 parent 9964cf8 commit f822e80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Data/AlphaNum.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getLengthInBits():int{
}

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{
Expand Down
9 changes: 9 additions & 0 deletions tests/Data/AlphaNumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public static function stringValidateProvider():array{
return [
['ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:', true],
['abc', false],
['ÄÖÜ', false],
[',', true],
['-', true],
['+', true],
['.', true],
['*', true],
[':', true],
['/', true],
['\\', false],
];
}

Expand Down

0 comments on commit f822e80

Please sign in to comment.