Skip to content

Route not found with UTF-8 parameter name #41909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TeLiXj opened this issue Jun 30, 2021 · 7 comments · Fixed by #45054
Closed

Route not found with UTF-8 parameter name #41909

TeLiXj opened this issue Jun 30, 2021 · 7 comments · Fixed by #45054

Comments

@TeLiXj
Copy link
Contributor

TeLiXj commented Jun 30, 2021

Symfony version(s) affected: 5.3.2 (at least)

Description
Routes with an UTF-8 parameter name can't be found.

How to reproduce
In YAML

informes:
    path: /informes/{año}
    controller: App\Controller\InformesController::anual

or attributes

#[Route("/informes/{año}", name: "informes")]
public function anual(string $año)
{
    dd($año);
}

Possible Solution
I don't know, I suppose that is a regression because I remember using this on Symfony 2 many years ago.

Additional context
I have tried with YAML, annotations and attributes and only in the last 5.3 version.
Any route with UTF-8 characters works fine, only fails with UTF-8 parameters name.
The routing.yaml have

framework:
    router:
        utf8: true

And add utf8: true to route options doesn't work either

@stof
Copy link
Member

stof commented Jun 30, 2021

I don't think UTF-8 parameter names were ever officially supported. If it worked in Symfony 2, it might be due to implementation details that were not doing anything incompatible with them. But the advanced usage of regex introduced in the url matcher rewrite might have changed that.

@nicolas-grekas
Copy link
Member

We could make it officially supported as a new feature, with proper test cases.
PR welcome @TeLiXj if you want to see it happen and can give it a try.

@TeLiXj
Copy link
Contributor Author

TeLiXj commented Jun 30, 2021

Well, I'll try to create a PR for this at the end of week :)

@OskarStark
Copy link
Contributor

Any news @TeLiXj ?

@TeLiXj
Copy link
Contributor Author

TeLiXj commented Jul 13, 2021

Not for now @OskarStark, I'm very busy this days

@Nyholm
Copy link
Member

Nyholm commented Jul 19, 2021

We could make it officially supported as a new feature

Sure, but should we?

I know PHP supports all kinds of weird variables. Like $☃️... https://3v4l.org/5YOfc

But I am not sure all kinds of characters has to be supported. I would rather document that only [a-zA-Z0-0_\-] is supported.

@TeLiXj
Copy link
Contributor Author

TeLiXj commented Jul 19, 2021

Thanks to @mazanax for the PR!
@Nyholm the regex used in that PR only accept all languages characters, no all UTF-8 characters.

@fabpot fabpot closed this as completed Jan 19, 2022
fabpot added a commit that referenced this issue Jan 19, 2022
…rekas)

This PR was merged into the 6.1 branch.

Discussion
----------

[Routing] Allow using UTF-8 parameter names

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #41909
| License       | MIT
| Doc PR        | -

Commits
-------

dfd852d [Routing] Allow using UTF-8 parameter names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants