Refer to steam method

This commit is contained in:
James Cole 2021-10-03 06:05:30 +02:00
parent 1e0e5d0fe9
commit 5d71baa4a1
No known key found for this signature in database
GPG Key ID: BDE6667570EADBD5

View File

@ -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.
*