Description
Symfony version(s) affected: 4.4 5.2?
Description
As I mentioned here #40701 (comment). The problem not only in UrlGenerator. Router does not check important (I mean started with !
) params inline requirements at all. I decided to open separate issue, because it could be more dangerous and it can be fixed separately.
How to reproduce
Create route with important param, and set some inline requirements like:
#[Route('/foo/{!id<\d+>}')]
Open /foo/bar
url and yes route matches the requirement
Reason
symfony/src/Symfony/Component/Routing/RouteCompiler.php
Lines 125 to 128 in 1d8ad1d
$varName does not start with
!
However Route requirement key starts with
!
, and param requirement set do default regex like [^/]++
Possible Solution
symfony/src/Symfony/Component/Routing/Route.php
Lines 536 to 552 in 1d8ad1d
Do not include
!
in requirement key.However it does not fix defaults for UrlGenerator described here #40701