From 755205b0688736918ac7c960fc9de4312d34e8cc Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@networkteam.com>
Date: Thu, 7 Sep 2017 22:24:17 +0200
Subject: [PATCH] [TASK] Improve prevention of redirect loop

This prevents a redirect loop with realurl where an editor
doesn't see the pagetree of his login domain in his workspace
and opens his login domain in the FE. As result he sees the
requested page.

Resolves: #82297
Releases: master, 8.7
Change-Id: Ie948f6defa21e3e1d8766533f54a48769d2220c9
Reviewed-on: https://review.typo3.org/53977
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Sascha Rademacher <sascha.rademacher+typo3@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Henning Liebe <h.liebe@neusta.de>
Reviewed-by: Steffen Frese <steffenf14@gmail.com>
Reviewed-by: Reiner Teubner <rteubner@me.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
---
 .../Classes/Controller/TypoScriptFrontendController.php         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
index c340323cbf24..d580ccf9112c 100644
--- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
+++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
@@ -2968,7 +2968,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
             'addQueryString.' => ['exclude' => 'id']]);
 
         // Prevent redirection loop
-        if (!empty($redirectUrl)) {
+        if (!empty($redirectUrl) && GeneralUtility::getIndpEnv('REQUEST_URI') !== '/' . $redirectUrl) {
             // redirect and exit
             HttpUtility::redirect($redirectUrl, HttpUtility::HTTP_STATUS_307);
         }
-- 
GitLab