Skip to content

Routing transforms url #47110

Closed
Closed
@pcmanprogrammeur

Description

@pcmanprogrammeur

Symfony version(s) affected

5.4

Description

Hi all,
We have a thesaurus with german localities like :

  • name : Baden-Württemberg
  • url : Baden-W%C3%BCrttemberg

When we use path() function in twig, the url is again encoded Baden-W%25C325%BCrttemberg so i call url_decode() to keep to good url ...
When we are in the controller, Baden-W%C3%BCrttemberg is decoded due to : $pathinfo = rawurldecode($pathinfo) ?: '/'; in CompiledUrlMatcherTrait.php and i don't find Baden-Württemberg in database ...
Why does the routing package change all my urls please ?
Adding url_decode and urlencode is bad ...

How to reproduce

In twig :
{{ path('my_path', {'region': 'Baden-W%C3%BCrttemberg')}) }} => my_path/Baden-W%25C3%25BCrttemberg
{{ path('my_path', {'region': url_decode('Baden-W%C3%BCrttemberg')}) }} => my_path/Baden-W%C3%BCrttemberg
I must add url_decode() to make it works properly ...

In controller :
$localilty = urlencode($locality);
// Before : Baden-Württemberg After : Baden-W%C3%BCrttemberg
$myService->getLocality($locality);
I must add urlencode() to make it works properly ...

Possible Solution

No response

Additional Context

No response

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