slimphp / slimphp/Slim

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

Open
#3,374 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Slim 5
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.