Parameter "x" for route "x" must match ".+"

Created on 12 October 2020, over 4 years ago
Updated 14 February 2025, about 2 months ago

Problem/Motivation

When passing a certain value as route parameter with requirement .+, it passes the first check in Drupal\Core\Routing\Router::doMatchCollection but not the second check in Drupal\Core\Routing\UrlGenerator::doGenerate, causing a WSOD.

The problem is that in the first check, the Dsu flags are included in the regex and in the second check, they aren't.

The website encountered an unexpected error. Please try again later.

Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "param" for route "wmcustom.test" must match ".+" ("L2VuL25vZGUvaGVscA==> BCC:ffyvwtrx7tkzb1x29hrn90x9p0vuju7m1as2fs3h@burpcollaborator.net svd: t" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 204 of core/lib/Drupal/Core/Routing/UrlGenerator.php).
Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute('wmcustom.test', Object, Array) (Line: 133)
Drupal\Core\Routing\UrlGenerator->getPathFromRoute('wmcustom.test', Array) (Line: 68)
Drupal\Core\Render\MetadataBubblingUrlGenerator->getPathFromRoute('wmcustom.test', Array) (Line: 791)
Drupal\Core\Url->getInternalPath() (Line: 99)
Drupal\Core\Path\PathMatcher->isFrontPage() (Line: 9)
Drupal\wmcustom\Controller\TestController->show('L2VuL25vZGUvaGVscA==>
BCC:ffyvwtrx7tkzb1x29hrn90x9p0vuju7m1as2fs3h@burpcollaborator.net
svd: t')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 25)
Drupal\wmcustom\Middleware\CachePermanentRedirectMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\wmcontroller\Http\Middleware\Cache->handle(Object, 1, 1) (Line: 47)
Drupal\wmsearch\Middleware\EarlyJson->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 65)
Drupal\wmcustom\Middleware\SuffixWildcardMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 39)
Drupal\wmcustom\Middleware\FtlMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 694)
Drupal\Core\DrupalKernel->handle(Object) (Line: 21)

Steps to reproduce

Check this gist for a code example. The second check is not always triggered, path.matcher::isFrontPage does it in this example.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

routing system

Created by

🇧🇪Belgium dieterholvoet Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024