Skip to content
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

Routing does not match (slash %2F in path parameter) #3374

Open
Magnum5234 opened this issue Mar 3, 2025 · 1 comment
Open

Routing does not match (slash %2F in path parameter) #3374

Magnum5234 opened this issue Mar 3, 2025 · 1 comment

Comments

@Magnum5234
Copy link

When you have the following route:

$router->any('/something/{magic}/{foo}', function (ServerRequestInterface $request, Response $response, array $args) use ($app) {
   // do something 
});

And Call this URL:

https://some.host/something/magic/foo%2Fbar

It will not match. I tried to check what went wrong. In $_SERVER I get:

["REQUEST_URI"]=>
  string(32) "/something/magic/foo%2Fbar"

It however matches when commenting out: https://github.com/slimphp/Slim/blob/4.x/Slim/Routing/RouteResolver.php#L42

Not sure why this is there tbh? If you want the route parameter to be decoded, shouldn't this be done after routing is done?

@mikespub
Copy link

mikespub commented Mar 4, 2025

It seems the rawurldecode($uri) was originally added to solve another issue for routes with international characters before Slim 4:

See commit 9c50cb9 in PR #2405 for issue #2399

For the specific case of %2F here that is indeed not expected if you compare with the comment $uri Should be $request->getUri()->getPath(). In fact PSR-7 gives that explicit example for getPath() when talking about percent-encoded values.

But I guess it's been around for so long now (2018) that this is a "known quirk" for Slim 4 routing? Work-around could be to double-encode %2F into %252F first...

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

No branches or pull requests

2 participants