From eb005270166dbca16a2145ba155f9d3369f1bb20 Mon Sep 17 00:00:00 2001 From: Danny van Wijk Date: Wed, 13 Nov 2024 11:32:47 +0100 Subject: [PATCH] Allow space inside redirect --- src/Kunstmaan/RedirectBundle/Router/RedirectRouter.php | 2 +- .../RedirectBundle/Tests/Router/RedirectRouterTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Kunstmaan/RedirectBundle/Router/RedirectRouter.php b/src/Kunstmaan/RedirectBundle/Router/RedirectRouter.php index 56dfc03fec..53364ac75d 100644 --- a/src/Kunstmaan/RedirectBundle/Router/RedirectRouter.php +++ b/src/Kunstmaan/RedirectBundle/Router/RedirectRouter.php @@ -151,7 +151,7 @@ private function initRouteCollection(string $pathInfo): void } } - $route = new Route($routePath, [ + $route = new Route(urldecode($routePath), [ '_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'path' => $targetPath, 'permanent' => $redirect->isPermanent(), diff --git a/src/Kunstmaan/RedirectBundle/Tests/Router/RedirectRouterTest.php b/src/Kunstmaan/RedirectBundle/Tests/Router/RedirectRouterTest.php index 1d3f59fb9f..24b1168382 100644 --- a/src/Kunstmaan/RedirectBundle/Tests/Router/RedirectRouterTest.php +++ b/src/Kunstmaan/RedirectBundle/Tests/Router/RedirectRouterTest.php @@ -76,6 +76,7 @@ public function urlProviderForImprovedRouter(): iterable yield 'Wildcard root origin to wildcard root target redirect with query params' => ['/test/abc/def?query=test', 'https://www.google.com/test/abc/def?query=test', $this->getRedirect(12, '/*', 'https://www.google.com/*')]; yield 'Wildcard root origin to wildcard root target with root path should not redirect' => ['/', null, $this->getRedirect(13, '/*', 'https://www.google.com/*')]; yield 'Redirect with query params' => ['/test?query=test', 'https://www.google.com/test?query=test', $this->getRedirect(14, '/test', 'https://www.google.com/test')]; + yield 'Wildcard root origin to wildcard root target redirect with spaces' => ['/test/abc/%20def?query=test', 'https://www.google.com/test/abc/%20def?query=test', $this->getRedirect(15, '/*', 'https://www.google.com/*')]; } private function getRedirect(int $id, string $origin, string $target, bool $permanent = false, ?string $domain = null): Redirect