From de109888a60d30245335b0bce86d5b1f45cee5a8 Mon Sep 17 00:00:00 2001 From: Chris Hilsdon Date: Fri, 18 Aug 2017 15:48:04 +0100 Subject: [PATCH 1/2] Enable 'Jump Links' again --- src/Redirector/Redirector.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Redirector/Redirector.php b/src/Redirector/Redirector.php index cc327a4..49b5cf6 100644 --- a/src/Redirector/Redirector.php +++ b/src/Redirector/Redirector.php @@ -33,15 +33,21 @@ public function __construct(Config $config) */ public function handle(Request $request, Application $app) { - $path = trim($request->getPathInfo(), '/'); foreach ($this->config->getRedirects() as $redirect) { $redirect->prepare(); - if($redirect->match($path)){ - return $app->redirect('/' . $redirect->getResult($path), 301); + if ($redirect->match($path)) { + $result = $redirect->getResult($path); + + // Only prefix Bolt redirects + if (substr($result, 0, 4 ) !== "http") { + $result = '/' . $result; + } + + return $app->redirect($result, 301); } } } -} +} \ No newline at end of file From 46064a688ceea28fc13d7bab46ca1a7b96c97022 Mon Sep 17 00:00:00 2001 From: Chris Hilsdon Date: Fri, 18 Aug 2017 16:08:42 +0100 Subject: [PATCH 2/2] Also allow redirects to ftp --- src/Redirector/Redirector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Redirector/Redirector.php b/src/Redirector/Redirector.php index 49b5cf6..55c4b27 100644 --- a/src/Redirector/Redirector.php +++ b/src/Redirector/Redirector.php @@ -42,7 +42,7 @@ public function handle(Request $request, Application $app) $result = $redirect->getResult($path); // Only prefix Bolt redirects - if (substr($result, 0, 4 ) !== "http") { + if (!preg_match("~^(https?|ftps?)\://~", $result)) { $result = '/' . $result; }