-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing][AnnotationClassLoader] fix utf-8 encoding in default route name #31421
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
Conversation
I don't see why the |
I'd suspect because strtolower is locale-sensitive. We could have something like: $name = str_replace('\\', '_', $class->name).'_'.$method->name;
$name = \function_exists('mb_strtolower') && preg_match('//u', $name) ? mb_strtolower($name, 'UTF-8') : strtolower($name); |
@Tobion That's very interesting. From my experience, As for the BC break - keeping in mind that each bug fix can be considered a BC break - this method is used only when a route has no name. So, it could potentially be a problem for someone, who uses routing but does not name the routes. |
@nicolas-grekas As I understand, you want to check if the string contains a unicode character? |
that would break if any other encoding is used - mb requires knowing the charset before using it. |
|
LGTM, could you add a test case please? |
src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php
Outdated
Show resolved
Hide resolved
The tests are failing on appveyor. Windows doesn't like unicode names... We should find a test case that doesn't rely on the filesystem willingness :) |
I've changed the name of the fixture class and now all tests pass. By the way, I think there might be a few more similar unicode issues hidden inside the Symfony code, e.g. method |
Thank you @przemyslaw-bogusz. |
…ault route name (przemyslaw-bogusz) This PR was squashed before being merged into the 3.4 branch (closes #31421). Discussion ---------- [Routing][AnnotationClassLoader] fix utf-8 encoding in default route name | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT If controller, or one of its methods, contain a unicode character and you run: ``` ./bin/console debug:router ``` you get this:  This PR fixes it into this:  Commits ------- 7ab52d3 [Routing][AnnotationClassLoader] fix utf-8 encoding in default route name
If controller, or one of its methods, contain a unicode character and you run:
you get this:

This PR fixes it into this:
