Closed robodal closed 1 month ago
Oh, good catch. Some of those characters should be escaped, I guess I'll just regex that bit the regular way then.
Ok, so I added a test case similar to the example you posted and it runs without issues with the charmap string linked above. However, the issue occurs if the minus within the charmap is moved to the end after the colon, in which case it is interpreted as meta-character. Either way i think I'm gonna change the regex to make it foolproof.
This is it. The minus it kind of problematic within the regex, it has to be in a specific position to not cause problems apparently, but also it can't be escaped as this would break the regex too.
preg_match('/^[A-Z\d %$*+-.:\/]+$/', $string);
https://github.com/chillerlan/php-qrcode/blob/9964cf8ff1ad90d17c360bd320cf18e16cd59829/src/Data/AlphaNum.php#L30
https://onlinephp.io/c/215012
(bool)preg_match('#^[+-.]+$#', ',') = true BUT (bool)preg_match('#^[+.-]+$#', ',') = false