Upstream nikic/FastRoute state of the touched files before e76ad24228
This commit is contained in:
1 parent
7ac8857878
commit
5861a25d71
6 files changed
+9
-62
No files matched your search
@@ -13,11 +13,8 @@ use FastRoute\Dispatcher\Result\MethodNotAllowed;
|
||||
use FastRoute\Dispatcher\Result\NotMatched;
|
||||
use PHPUnit\Framework\Attributes as PHPUnit;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RuntimeException;
|
||||
|
||||
use function FastRoute\simpleDispatcher;
|
||||
use function ini_set;
|
||||
use function str_repeat;
|
||||
|
||||
/** @phpstan-import-type ExtraParameters from DataGenerator */
|
||||
abstract class DispatcherTestCase extends TestCase
|
||||
@@ -180,36 +177,6 @@ abstract class DispatcherTestCase extends TestCase
|
||||
}, $this->generateDispatcherOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* A PCRE engine failure must surface instead of being reported as
|
||||
* NOT_FOUND for an unrelated route in the same combined regex chunk.
|
||||
*
|
||||
* @see https://github.com/nikic/FastRoute/issues/167
|
||||
*/
|
||||
#[PHPUnit\Test]
|
||||
public function regexEngineFailureIsNotSilentlyTreatedAsNotFound(): void
|
||||
{
|
||||
$previousLimit = ini_set('pcre.backtrack_limit', '1000');
|
||||
self::assertNotFalse($previousLimit, 'Unable to lower pcre.backtrack_limit for this test');
|
||||
|
||||
try {
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionMessageMatches('/Backtrack limit exhausted/');
|
||||
|
||||
$dispatcher = simpleDispatcher(static function (ConfigureRoutes $r): void {
|
||||
// Catastrophically backtracking pattern.
|
||||
$r->addRoute('GET', '/{p:(?:a?a?)*}/complicated', 'complicated_pattern');
|
||||
// Cheap route in the same chunk: it would match on its own, but the
|
||||
// chunk's preg_match() call fails.
|
||||
$r->addRoute('GET', '/{p:a+}', 'cheap_route');
|
||||
}, $this->generateDispatcherOptions());
|
||||
|
||||
$dispatcher->dispatch('GET', '/' . str_repeat('a', 30));
|
||||
} finally {
|
||||
ini_set('pcre.backtrack_limit', $previousLimit);
|
||||
}
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{0: string, 1: string, 2: Closure(ConfigureRoutes):void, 3: string, 4?: array<string, string>}> */
|
||||
public static function provideFoundDispatchCases(): iterable
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user