Skip to content

Commit

Permalink
simplify some more
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Jan 5, 2024
1 parent 40dfb1f commit 8d8005b
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions framework/core/src/Forum/Controller/LogOutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') ?? []
Expand Down

0 comments on commit 8d8005b

Please sign in to comment.