diff --git a/framework/core/src/Forum/Controller/LogOutController.php b/framework/core/src/Forum/Controller/LogOutController.php index 1c88417f56..1f18214035 100644 --- a/framework/core/src/Forum/Controller/LogOutController.php +++ b/framework/core/src/Forum/Controller/LogOutController.php @@ -126,26 +126,24 @@ public function handle(Request $request): ResponseInterface protected function sanitizeReturnUrl(string $url, string $base): Uri { - $parsedBase = new Uri($base); if (empty($url)) { - return $parsedBase; // Return base URL for empty return URL + return new Uri($base); } - - $parsed = new Uri($url); - $host = $parsed->getHost(); + $parsedUrl = new Uri($url); - if (in_array($host, $this->getWhitelistedRedirectDomains())) { - return $parsed; + if (in_array($parsedUrl->getHost(), $this->getWhitelistedRedirectDomains())) { + return $parsedUrl; } - return $parsedBase; // Return base url for non-whitelisted domains + return new Uri($base); } + protected function getWhitelistedRedirectDomains(): array { $forumUri = new Uri($this->config->url()); - + return array_merge( [$forumUri->getHost()], $this->config->offsetGet('redirectDomains') ?? []