From 52ba79f95400f3ef0047af71ad470d959a49a135 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 11 Sep 2019 19:49:47 +0300 Subject: [PATCH] Fixed redirect with absolute language URL --- CHANGELOG.md | 3 ++- classes/plugin/Admin.php | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1a96ae3..2ae615e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ * Add ability to Sanitize SVGs on file upload * Add ability to Sanitize SVGs in Page media 1. [](#bugfix) - * Keep language setting for AJAX requests + * Fixed missing language for AJAX requests + * Fixed redirect with absolute language URL # v1.10.0-beta.7 ## 08/30/2019 diff --git a/classes/plugin/Admin.php b/classes/plugin/Admin.php index 89b302f1..84f50a9b 100644 --- a/classes/plugin/Admin.php +++ b/classes/plugin/Admin.php @@ -369,8 +369,11 @@ class Admin $root = ''; } - // Check if we already have an admin path: /admin or /root/admin. - if (Utils::startsWith($redirect, $base, false) || Utils::startsWith($redirect, $root . $base, false)) { + $pattern = '|^((' . preg_quote($root, '|') . ')?\/[\w\d_-]+)' . preg_quote($base, '|') . '|ui'; + // Check if we already have an admin path: /admin, /en/admin, /root/admin or /root/en/admin. + if (preg_match($pattern, $redirect)) { + $redirect = preg_replace('|^' . preg_quote($root, '|') . '|', '', $redirect); + $this->grav->redirect($redirect, $redirectCode); }