Skip to content

Commit 43fcfc3

Browse files
committed
Route: fixed checking for missing [
1 parent 52d68c0 commit 43fcfc3

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/Application/Routers/Route.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ private function setMask($mask, array $metadata)
457457
}
458458
}
459459

460-
if (strpbrk($mask, '?<[') === FALSE) {
460+
if (strpbrk($mask, '?<[]') === FALSE) {
461461
$this->re = '#' . preg_quote($mask, '#') . '/?\z#A';
462462
$this->sequence = [$mask];
463463
$this->metadata = $metadata;
@@ -598,7 +598,7 @@ private function setMask($mask, array $metadata)
598598
} while (TRUE);
599599

600600
if ($brackets) {
601-
throw new Nette\InvalidArgumentException("Missing closing ']' in mask '$mask'.");
601+
throw new Nette\InvalidArgumentException("Missing '[' in mask '$mask'.");
602602
}
603603

604604
$this->aliases = $aliases;

tests/Routers/Route.errors.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/**
4+
* Test: Nette\Application\Routers\Route errors.
5+
*/
6+
7+
use Nette\Application\Routers\Route;
8+
use Tester\Assert;
9+
10+
11+
require __DIR__ . '/../bootstrap.php';
12+
13+
14+
Assert::exception(function () {
15+
$route = new Route('[a');
16+
}, Nette\InvalidArgumentException::class, "Unexpected '[' in mask '[a'.");
17+
18+
Assert::exception(function () {
19+
$route = new Route('a]');
20+
}, Nette\InvalidArgumentException::class, "Missing '[' in mask 'a]'.");

0 commit comments

Comments
 (0)