mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Refer to steam method
This commit is contained in:
parent
1e0e5d0fe9
commit
5d71baa4a1
@ -202,7 +202,7 @@ class Handler extends ExceptionHandler
|
||||
protected function invalid($request, LaravelValidationException $exception): Application|RedirectResponse|Redirector
|
||||
{
|
||||
// protect against open redirect when submitting invalid forms.
|
||||
$previous = $this->getPreviousUrl();
|
||||
$previous = app('steam')->getSafePreviousUrl();
|
||||
$redirect = $this->getRedirectUrl($exception);
|
||||
|
||||
return redirect($redirect ?? $previous)
|
||||
@ -210,21 +210,6 @@ class Handler extends ExceptionHandler
|
||||
->withErrors($exception->errors(), $request->input('_error_bag', $exception->errorBag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Only return the previousUrl() if it is a valid URL. Return default redirect otherwise.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getPreviousUrl(): string
|
||||
{
|
||||
$safe = route('index');
|
||||
$previous = url()->previous();
|
||||
$previousHost = parse_url($previous, PHP_URL_HOST);
|
||||
$safeHost = parse_url($safe, PHP_URL_HOST);
|
||||
|
||||
return null !== $previousHost && $previousHost === $safeHost ? $previous : $safe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only return the redirectTo property from the exception if it is a valid URL. Return NULL otherwise.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user