Skip to content

Routing parameter mismatch #27461

@emarref

Description

@emarref

Symfony version(s) affected: 4.1.0

Description
A complex host requirement in a route definition causes unexpected resolution of request attributes. This behaviour is not present in 4.0.11 or 3.4.11.

How to reproduce
Create a route with a default host, and a complex host requirement. Request parameters will be off by one. Bug reproducer: https://github.com/emarref/symfony-routing-bug

Detail
Given a route path of /{app}/{action}/{unused} and browsing http://127.0.0.1:8000/an_app/an_action/unused I'd expect to see request attributes like this:

array:4 [▼
  "host" => "127.0.0.1"
  "app" => "an_app"
  "action" => "an_action"
  "unused" => "unused"
]

But I am incorrectly seeing this:

array:4 [▼
  "host" => "127.0.0.1"
  "app" => "0"
  "action" => "an_app"
  "unused" => "an_action"
]

N.b. The app, action, and unused params are mismatched. The value of app is from the hostname in the URL.

If I set a hosts file entry so that my.awesome.website.com resolves to 127.0.0.1, I see this:

array:4 [▼
  "host" => "my.awesome.website.com"
  "app" => "website"
  "action" => "an_app"
  "unused" => "an_action"
]

This seems to be caused by the host requirement regex. If I set a more permissive regex (e.g. .*), everything works as expected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions