Skip to content

Commit

Permalink
Trim model class name (#25849)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ankurk91 authored and taylorotwell committed Oct 1, 2018
1 parent 4102928 commit 54d3383
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/Middleware/Authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 54d3383

Please sign in to comment.