From 80ec23caa633af3d14553dc39c6e93f7c43cd67b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 14 Aug 2026 18:16:33 +1200 Subject: [PATCH] fix: stringify non-scalar abuse rate-limit params --- app/controllers/shared/api.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index b52b8e552a..b878e19279 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -528,9 +528,14 @@ Http::init() ->setParam('{chunkId}', (int) ($start / ($end + 1 - $start))); foreach ($request->getParams() as $key => $value) { - if (! empty($value)) { - $timeLimit->setParam('{param-' . $key . '}', (\is_array($value)) ? \json_encode($value) : $value); + if ($value === null || $value === '' || $value === []) { + continue; } + $encoded = \is_scalar($value) ? (string) $value : \json_encode($value); + if ($encoded === false || $encoded === '') { + continue; + } + $timeLimit->setParam('{param-' . $key . '}', $encoded); } $abuse = new Abuse($timeLimit); @@ -907,10 +912,15 @@ Http::shutdown() ->setParam('{method}', $request->getMethod()) ->setParam('{chunkId}', (int) ($start / ($end + 1 - $start))); - foreach ($request->getParams() as $key => $value) { // Set request params as potential abuse keys - if (! empty($value)) { - $timeLimit->setParam('{param-' . $key . '}', (\is_array($value)) ? \json_encode($value) : $value); + foreach ($request->getParams() as $key => $value) { + if ($value === null || $value === '' || $value === []) { + continue; } + $encoded = \is_scalar($value) ? (string) $value : \json_encode($value); + if ($encoded === false || $encoded === '') { + continue; + } + $timeLimit->setParam('{param-' . $key . '}', $encoded); } $abuse = new Abuse($timeLimit);