diff --git a/typo3/sysext/redirects/Classes/Http/Middleware/RedirectHandler.php b/typo3/sysext/redirects/Classes/Http/Middleware/RedirectHandler.php index 39cec49cf08909e9ac180679b951b01e40bb6dae..074e8f891d71d021e6212a4b1b2e5c77b60c82ea 100644 --- a/typo3/sysext/redirects/Classes/Http/Middleware/RedirectHandler.php +++ b/typo3/sysext/redirects/Classes/Http/Middleware/RedirectHandler.php @@ -66,7 +66,11 @@ class RedirectHandler implements MiddlewareInterface, LoggerAwareInterface $url = $this->redirectService->getTargetUrl($matchedRedirect, $request); if ($url instanceof UriInterface) { if ($this->redirectUriWillRedirectToCurrentUri($request, $url)) { - if ($url->getFragment()) { + if ($this->isEmptyRedirectUri($url)) { + // Empty uri leads to a redirect loop in Firefox, whereas Chrome would stop it but not displaying anything. + // @see https://forge.typo3.org/issues/100791 + $this->logger->error('Empty redirect points to itself! Aborting.', ['record' => $matchedRedirect, 'uri' => (string)$url]); + } elseif ($url->getFragment()) { // Enrich error message for unsharp check with target url fragment. $this->logger->error('Redirect ' . $url->getPath() . ' eventually points to itself! Target with fragment can not be checked and we take the safe check to avoid redirect loops. Aborting.', ['record' => $matchedRedirect, 'uri' => (string)$url]); } else { @@ -120,6 +124,9 @@ class RedirectHandler implements MiddlewareInterface, LoggerAwareInterface */ protected function redirectUriWillRedirectToCurrentUri(ServerRequestInterface $request, UriInterface $redirectUri): bool { + if ($this->isEmptyRedirectUri($redirectUri)) { + return true; + } $requestUri = $request->getUri(); $redirectIsAbsolute = $redirectUri->getHost() && $redirectUri->getScheme(); $requestUri = $this->sanitizeUriForComparison($requestUri, !$redirectIsAbsolute); @@ -180,4 +187,13 @@ class RedirectHandler implements MiddlewareInterface, LoggerAwareInterface return $uri; } + + /** + * Empty uri leads to a redirect loop in Firefox, whereas Chrome would stop it but not displaying anything. + * @see https://forge.typo3.org/issues/100791 + */ + private function isEmptyRedirectUri(UriInterface $uri): bool + { + return (string)$uri === ''; + } }