From 54d33832ec1e9c3c0a894c941334e2a6ba6d2be6 Mon Sep 17 00:00:00 2001 From: Ankur Kumar Date: Mon, 1 Oct 2018 18:45:55 +0530 Subject: [PATCH] Trim model class name (#25849) When passing php class names in middleware, for example ``` ->middleware('can:create, App\Models\JobDocument); ``` Developer can accidentally add a whitespace before class name. This whitespace will cause the linked policy to not found and cause a 403 http response. --- src/Illuminate/Auth/Middleware/Authorize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Auth/Middleware/Authorize.php b/src/Illuminate/Auth/Middleware/Authorize.php index 04c692146724..d1774d79116d 100644 --- a/src/Illuminate/Auth/Middleware/Authorize.php +++ b/src/Illuminate/Auth/Middleware/Authorize.php @@ -72,7 +72,7 @@ protected function getGateArguments($request, $models) */ protected function getModel($request, $model) { - return $this->isClassName($model) ? $model : $request->route($model, $model); + return $this->isClassName($model) ? trim($model) : $request->route($model, $model); } /**