From 03e84852b4e8394444eadc71ae3c66c19edf954f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Einar=20Gangs=C3=B8?= Date: Fri, 19 Sep 2025 10:41:26 +0200 Subject: [PATCH 1/3] Do not use AlphaNum when string contains comma Using dash in this context will create a range between `+` and `.` which allows the following characters: `+`, `,`, `-`, `.`. The ASCII range is as follow: + (43), , (44), - (45), . (46). Comma is not supported and will then crash in `write()`. --- src/Data/AlphaNum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/AlphaNum.php b/src/Data/AlphaNum.php index 961d6b774..e19467b73 100644 --- a/src/Data/AlphaNum.php +++ b/src/Data/AlphaNum.php @@ -36,7 +36,7 @@ public function getLengthInBits():int{ } public static function validateString(string $string):bool{ - return (bool)preg_match('/^[A-Z\d %$*+-.:\/]+$/', $string); + return (bool)preg_match('/^[A-Z\d %$*+\-.:\/]+$/', $string); } public function write(BitBuffer $bitBuffer, int $versionNumber):static{ From 5d82e8e8c9ecdf9a4f6df5f34f4d7db720d4040a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Einar=20Gangs=C3=B8?= Date: Fri, 19 Sep 2025 10:45:37 +0200 Subject: [PATCH 2/3] Update tests, comma is not supported --- tests/Data/AlphaNumTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Data/AlphaNumTest.php b/tests/Data/AlphaNumTest.php index eeb2c2631..74df269b0 100644 --- a/tests/Data/AlphaNumTest.php +++ b/tests/Data/AlphaNumTest.php @@ -35,7 +35,7 @@ public static function stringValidateProvider():array{ ['ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:', true], ['abc', false], ['ÄÖÜ', false], - [',', true], + [',', false], ['-', true], ['+', true], ['.', true], @@ -43,6 +43,7 @@ public static function stringValidateProvider():array{ [':', true], ['/', true], ['\\', false], + ['0,1', false] ]; } From 29cdbcc8cddc6eb5445b4eaffd44d6ec660822b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Einar=20Gangs=C3=B8?= Date: Fri, 19 Sep 2025 14:17:21 +0200 Subject: [PATCH 3/3] Remove uneeded test --- tests/Data/AlphaNumTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Data/AlphaNumTest.php b/tests/Data/AlphaNumTest.php index 74df269b0..ed7a97c16 100644 --- a/tests/Data/AlphaNumTest.php +++ b/tests/Data/AlphaNumTest.php @@ -43,7 +43,6 @@ public static function stringValidateProvider():array{ [':', true], ['/', true], ['\\', false], - ['0,1', false] ]; }