Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions lib/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,19 @@ private function buildProtocolErrorResponse(?bool $throttle = null): TemplateRes
* @return RedirectResponse
*/
private function getRedirectResponse(?string $redirectUrl = null): RedirectResponse {
return new RedirectResponse(
$redirectUrl === null
? $this->urlGenerator->getBaseUrl()
: preg_replace('/^https?:\/\/[^\/]+/', '', $redirectUrl)
);
if ($redirectUrl === null) {
return new RedirectResponse($this->urlGenerator->getBaseUrl());
}

// Remove protocol and domain name
$filtered = preg_replace('/^https?:\/\/[^\/]+/', '', $redirectUrl);

// Additional check: ensure the result starts with a single /
if (!preg_match('/^\/[^\/]/', $filtered)) {
return new RedirectResponse($this->urlGenerator->getBaseUrl());
}

return new RedirectResponse($filtered);
}

/**
Expand Down
Loading