Skip to content

Commit

Permalink
use clearer config key
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Jan 4, 2024
1 parent bf95872 commit b363023
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions framework/core/src/Forum/Controller/LogOutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function handle(Request $request): ResponseInterface
$return = $this->sanitizeReturnUrl($request->getQueryParams()['return'] ?? $base);

$view = $this->view->make('flarum.forum::log-out')
->with('url', $this->url->to('forum')->route('logout').'?token='.$csrfToken.($return ? '&return='.urlencode($return) : ''));
->with('url', $this->url->to('forum')->route('logout') . '?token=' . $csrfToken . ($return ? '&return=' . urlencode($return) : ''));

return new HtmlResponse($view->render());
}
Expand All @@ -128,8 +128,8 @@ protected function sanitizeReturnUrl(string $url): string
{
$parsed = parse_url($url);

if (! $parsed || ! isset($parsed['host'])) {
return '';
if (!$parsed || !isset($parsed['host'])) {
return ''; // Return early for invalid URLs
}

$host = $parsed['host'];
Expand All @@ -138,14 +138,14 @@ protected function sanitizeReturnUrl(string $url): string
return $url;
}

return '';
return ''; // Return empty string for non-whitelisted domains
}

protected function getWhitelistedRedirectDomains(): array
{
return array_merge(
[$this->config->url()],
$this->config->offsetGet('trustedHosts') ?? []
$this->config->offsetGet('redirectDomains') ?? []
);
}
}

0 comments on commit b363023

Please sign in to comment.