Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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('/^[A-Z\d %$*+-.:\/]+$/', $string);
return (bool)preg_match('/^[A-Z\d %$*+\-.:\/]+$/', $string);
}

public function write(BitBuffer $bitBuffer, int $versionNumber):static{
Expand Down
2 changes: 1 addition & 1 deletion tests/Data/AlphaNumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function stringValidateProvider():array{
['ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:', true],
['abc', false],
['ÄÖÜ', false],
[',', true],
[',', false],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think perhaps the tests should actually try to generate a QR with this data too. As it will crash in AlphaNum::ord(). Would have revealed this bug earlier.

Copy link
Contributor Author

@eigan eigan Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataInterfaceTestAbstract

	public function testValidateString(string $string, bool $expected):void{
		$this::assertSame($expected, $this->dataMode::validateString($string));

		try {
			$qrCode      = new QRCode;
			$qrCode->addSegment(static::getDataModeInterface($string));
			$qrCode->renderMatrix($qrCode->getQRMatrix());
			self::assertTrue($expected);
		} catch(\Exception){
			self::assertFalse($expected);
		}
	}

This can also reveal the real bug while in main.

['-', true],
['+', true],
['.', true],
Expand Down
Loading