From 5d71baa4a18ebaaedb170278b4147d3452c8c6de Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 3 Oct 2021 06:05:30 +0200 Subject: [PATCH] Refer to steam method --- app/Exceptions/Handler.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index ba68632bd0..9b52ef9dc6 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -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. *