Skip to content

Commit

Permalink
Do not decode path before matching
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jul 3, 2024
1 parent c0434ad commit 56f4ade
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function handleRequest(Request $request): Response
}

$method = $request->getMethod();
$path = \rawurldecode($request->getUri()->getPath());
$path = $request->getUri()->getPath();

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

Expand Down
6 changes: 3 additions & 3 deletions test/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,18 @@ public function testMerge(): void
$this->assertEquals(HttpStatus::NOT_FOUND, $response->getStatus());
}

public function testPathIsMatchedDecoded(): void
public function testPathMatchIsEncoded(): void
{
$requestHandler = new ClosureRequestHandler(function () {
return new Response(HttpStatus::OK);
});

$router = new Router($this->server, $this->testLogger, $this->errorHandler);
$router->addRoute("GET", "/fo+ö", $requestHandler);
$router->addRoute("GET", "/fo+" . \rawurlencode(""), $requestHandler);

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

$uri = "/fo+" . \rawurlencode("ö");
$uri = "/fo+" . \rawurlencode("/ö");

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

0 comments on commit 56f4ade

Please sign in to comment.