File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,11 @@ public function index(Request $request) : array
162162
163163 if ($ request ->filled ('filter ' )) {
164164 $ filter = json_decode ($ request ->input ('filter ' ), true );
165+
166+ if (is_null ($ filter )) {
167+ $ filter = [];
168+ }
169+
165170 $ filter = array_filter ($ filter , function ($ key ) use ($ allowed_columns ) {
166171 return in_array ($ key , $ allowed_columns );
167172 }, ARRAY_FILTER_USE_KEY );
Original file line number Diff line number Diff line change @@ -57,4 +57,14 @@ public function testReturnsManagedLocationsCountCorrectly()
5757 ->etc ();
5858 });
5959 }
60+
61+ public function test_gracefully_handles_malformed_filter ()
62+ {
63+ $ this ->actingAsForApi (User::factory ()->viewUsers ()->create ())
64+ ->getJson (route ('api.users.index ' , [
65+ // filter should be a json encoded array and not a string
66+ 'filter ' =>
'email:[email protected] ' ,
67+ ]))
68+ ->assertOk ();
69+ }
6070}
You can’t perform that action at this time.
0 commit comments