Problem
active_for_routes() assumes the current request has a _route attribute.
If a request exists but the route attribute is missing, the helper can behave in a fragile way because the value is used directly in preg_match().
Current evidence
src/Twig/Extension/ActiveForRoutesExtension.php reads $request->attributes->get('_route')
- the value is then passed into
preg_match() without an explicit guard for missing or non-string values
Expected behavior
The helper should return an empty string when the current request does not provide a valid route name.
Suggested work
- guard the
_route value before matching
- treat missing or non-string route names as a non-match
- add tests that cover requests without
_route
Problem
active_for_routes()assumes the current request has a_routeattribute.If a request exists but the route attribute is missing, the helper can behave in a fragile way because the value is used directly in
preg_match().Current evidence
src/Twig/Extension/ActiveForRoutesExtension.phpreads$request->attributes->get('_route')preg_match()without an explicit guard for missing or non-string valuesExpected behavior
The helper should return an empty string when the current request does not provide a valid route name.
Suggested work
_routevalue before matching_route