Cannot use a / in route parameter

Created on 3 June 2016, about 8 years ago
Updated 23 February 2024, 4 months ago

Problem/Motivation

According to the Symfony documentation it should be possible to use a "/" (forward slash) in a route path by defining the pattern for a path component to allow any character (instructions here: https://symfony.com/doc/3.4/routing/slash_in_parameter.html)

However, in Drupal this doesn't work.

Steps to reproduce

For example, with the following route definition:

_hello:
    path:     /hello/{username}
    defaults: { _controller: AppBundle:Demo:hello }
    requirements:
        username: .+

the path '/hello/foo/bar' should work, and the controller should receive $username as 'foo/bar'.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Routing 

Last updated less than a minute ago

Created by

miiimooo Europe

Live updates comments and jobs are added and updated live.
  • needs profiling

    It may affect performance, and thus requires in-depth technical reviews and profiling.

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.

  • 🇮🇳India Raviknair45

    The Above patches work only upto 62 url parts after that route will be empty as $ancestors from getCandidateOutlines is having bitwise shift left condition of $end = (1 << $number_parts) - 1; which will skip the execution at https://git.drupalcode.org/project/drupal/-/blob/10.1.x/core/lib/Drupal/Core/Routing/RouteProvider.php#L297

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    This could use an issue summary update with proposed solution and remaining tasks. Think it would be a good spot for the profiling to happen also.

  • 🇬🇧United Kingdom joachim

    Updated the IS.

Production build 0.69.0 2024