Routing does not match (slash %2F in path parameter)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 12.3k
- Forks
- 2k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 6
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Slim/Routing/RouteResolver.php at the referenced line and reproduce the route with /something/{magic}/{foo} using the URL ending in foo%2Fbar. Check how the request path is handled before matching, then verify that the route matches and the decoded parameter values are available after routing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100