Selaa lähdekoodia

fix(api-v13): recent 查询校验 id 必须为 uuid,非法返回 422

visuddhinanda 2 päivää sitten
vanhempi
sitoutus
c0a490ec05
1 muutettua tiedostoa jossa 6 lisäystä ja 1 poistoa
  1. 6 1
      api-v13/app/Http/Controllers/RecentController.php

+ 6 - 1
api-v13/app/Http/Controllers/RecentController.php

@@ -21,7 +21,12 @@ class RecentController extends Controller
         //
         switch ($request->view) {
             case 'user':
-                $table = Recent::where('user_uid', $request->input('id'));
+                // recents.user_uid 是 uuid 列,非法值直接拒绝,避免 Postgres 报 22P02。
+                $userUid = $request->input('id');
+                if (! Str::isUuid($userUid)) {
+                    return $this->error('invalid id', [], 422);
+                }
+                $table = Recent::where('user_uid', $userUid);
                 break;
             default:
                 return $this->error('known view');