8000 [Router] Fix DumpedUrlMatcher behaviour with trailing slash by xavierleune · Pull Request #33362 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Router] Fix DumpedUrlMatcher behaviour with trailing slash #33362

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

Conversation

xavierleune
Copy link
Contributor
Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #32996
License MIT
Doc PR ¤

The trailing slash management seems not to be quite consistant across matchers. This pull request fixes the behaviour with the current state of mind: when you have an exact route, you should always use it, not trying to redirect request.

Things are a little bit tricky here, specially when it comes to the DumpedUrlMatcher, but it was adding a lot of complexity than trying to keep things in a single function.

@xavierleune xavierleune force-pushed the fix-32996-trailing-slash branch from 60997a8 to 8a2b788 Compare August 27, 2019 16:26
@nicolas-grekas
Copy link
Member

I just posted #32996 (comment), which I wrote offline before seeing this PR.

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Aug 27, 2019
@@ -115,17 +115,6 @@ public function testSchemeRequirement()
$this->assertSame(['_route' => 'foo'], $matcher->match('/foo'));
}

public function testFallbackPage()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guarded against the regression found in #29297

@nicolas-grekas
Copy link
Member

(Trick to update fixtures: add a file_put_contents() at the beginning of assertStringEqualsFile in .phpunit/phpunit-8.3-0/src/Framework/Assert.php or similar.)

@nicolas-grekas
Copy link
Member
nicolas-grekas commented Aug 29, 2019

Thank you for #32996 (comment) it helps understand your use case a lot.

I think there is no bug on 3.4 so that this PR shouldn't be merged.

Can you confirm routes like this allow working around the behavior that annoys you?

  • @Route("/hello{_</(?!/)>}", name="hello1")
  • @Route("/hello{_<(?!/)>}", name="hello2")

Would your use case be fixed by reconfiguring the router to use UrlMatcher instead of RedirectableUrlMatcher? That would remove the other redirections, so maybe not - but maybe yes if you don't use scheme redirects?

As a follow up, I'd suggest opening a new feature request. Global or local flag/option could be discussed there (we could have a per-route option, and be able to enable it by default like the utf8 one)

@xavierleune
Copy link
Contributor Author

Thanks, following this comment on #32996 I double checked things here and I think there is no bug either in 3.4 or in any 4.X version. Sorry you've lost some time here. So instead of trying to fix things according to documentation, I've opened a PR on symfony-docs#12247.
I also can confirm that the workaround you suggested is working perfectly fine.

So I'll reopen and rework #33342 to discuss about the global flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0