Skip to content

Commit 5655ecb

Browse files
committed
Do not decode %2F in path
1 parent c0434ad commit 5655ecb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Router.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ public function handleRequest(Request $request): Response
7474
}
7575

7676
$method = $request->getMethod();
77-
$path = \rawurldecode($request->getUri()->getPath());
77+
78+
$path = \str_ireplace('%2F', '%252F', $request->getUri()->getPath());
79+
$path = \rawurldecode($path);
7880

7981
$toMatch = "{$method}\0{$path}";
8082

test/RouterTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ public function testPathIsMatchedDecoded(): void
214214
});
215215

216216
$router = new Router($this->server, $this->testLogger, $this->errorHandler);
217-
$router->addRoute("GET", "/fo+ö", $requestHandler);
217+
$router->addRoute("GET", "/fo+%2Fö bar", $requestHandler);
218218

219219
$this->server->start($router, $this->errorHandler);
220220

221-
$uri = "/fo+" . \rawurlencode("ö");
221+
$uri = "/fo+%2F" . \rawurlencode("ö ") . 'bar';
222222

223223
$request = new Request($this->createMock(Client::class), "GET", Uri\Http::createFromString($uri));
224224
$response = $router->handleRequest($request);

0 commit comments

Comments
 (0)