Skip to content

Commit

Permalink
Merge pull request #1008 from nextcloud/artonge/fix/path_containing_c…
Browse files Browse the repository at this point in the history
…olon

fix: Handle redirect URL containing a ':'
  • Loading branch information
artonge authored Dec 11, 2024
2 parents 138da66 + 6296354 commit 433a630
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,10 @@ 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
? $this->urlGenerator->getBaseUrl()
: join('?', array_filter(parse_url($redirectUrl), fn ($k) => in_array($k, ['path', 'query']), ARRAY_FILTER_USE_KEY))
: preg_replace('/^https?:\/\/[^\/]+/', '', $redirectUrl)
);
}

Expand Down

0 comments on commit 433a630

Please sign in to comment.