mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-04 05:06:37 +00:00
Refer to steam method
This commit is contained in:
@@ -202,7 +202,7 @@ class Handler extends ExceptionHandler
|
|||||||
protected function invalid($request, LaravelValidationException $exception): Application|RedirectResponse|Redirector
|
protected function invalid($request, LaravelValidationException $exception): Application|RedirectResponse|Redirector
|
||||||
{
|
{
|
||||||
// protect against open redirect when submitting invalid forms.
|
// protect against open redirect when submitting invalid forms.
|
||||||
$previous = $this->getPreviousUrl();
|
$previous = app('steam')->getSafePreviousUrl();
|
||||||
$redirect = $this->getRedirectUrl($exception);
|
$redirect = $this->getRedirectUrl($exception);
|
||||||
|
|
||||||
return redirect($redirect ?? $previous)
|
return redirect($redirect ?? $previous)
|
||||||
@@ -210,21 +210,6 @@ class Handler extends ExceptionHandler
|
|||||||
->withErrors($exception->errors(), $request->input('_error_bag', $exception->errorBag));
|
->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.
|
* Only return the redirectTo property from the exception if it is a valid URL. Return NULL otherwise.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user