Skip to content

Commit

Permalink
use parse_url to get rid of the protocol+domain in the login redirect…
Browse files Browse the repository at this point in the history
… URL

Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Oct 10, 2024
1 parent 4038f12 commit 99f7b73
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,13 @@ private function buildProtocolErrorResponse(?bool $throttle = null): TemplateRes
* @return RedirectResponse
*/
private function getRedirectResponse(?string $redirectUrl = null): RedirectResponse {
// this could also be done with
// preg_replace('/^https?:\/\//', '', $redirectUrl)
// or even: if (preg_match('/https?:\/\//', $redirectUrl) === 1) return new RedirectResponse('/');
return new RedirectResponse(
$redirectUrl === null
? null
: preg_replace('/^https?:\/\//', '', $redirectUrl)
: parse_url($redirectUrl, PHP_URL_PATH)
);
}

Expand Down

0 comments on commit 99f7b73

Please sign in to comment.