Closed Benjamin-Loison closed 9 months ago
The following does not work (actually expected behavior):
diff --git a/videos.php b/videos.php
index de1bfa4..91a9d43 100644
--- a/videos.php
+++ b/videos.php
@@ -53,10 +53,16 @@
$isClip = isset($_GET['clipId']);
$field = $isClip ? 'clipId' : 'id';
$ids = $_GET[$field];
- $realIds = str_contains($ids, ',') ? explode(',', $ids, 50) : [$ids];
- if (count($realIds) == 0) {
+ $realIdsCountMax = 50;
+ $realIds = explode(',', $ids, $realIdsCountMax);
+ $realIdsCount = count($realIds);
+ if ($realIdsCount == 0) {
dieWithJsonMessage('Invalid id');
}
+ if ($realIdsCount > $realIdsCountMax)
+ {
+ dieWithJsonMessage('Too many id');
+ }
foreach ($realIds as $realId) {
if ((!$isClip && !isVideoId($realId)) && !isClipId($realId)) {
dieWithJsonMessage("Invalid $field");
However, the following works:
diff --git a/videos.php b/videos.php
index de1bfa4..f1b5261 100644
--- a/videos.php
+++ b/videos.php
@@ -53,9 +53,9 @@
$isClip = isset($_GET['clipId']);
$field = $isClip ? 'clipId' : 'id';
$ids = $_GET[$field];
- $realIds = str_contains($ids, ',') ? explode(',', $ids, 50) : [$ids];
- if (count($realIds) == 0) {
- dieWithJsonMessage('Invalid id');
+ $realIds = explode(',', $ids);
+ if (count($realIds) > 50) {
+ dieWithJsonMessage("Too many $field");
}
foreach ($realIds as $realId) {
if ((!$isClip && !isVideoId($realId)) && !isClipId($realId)) {
I have doubts that the following line can even be triggered.
Let us investigate when it was introduced. Well it was there since the beginning:
Without id
I get:
Required parameters not provided
With an empty id
I get:
Invalid id
from this line
This check seems to have always been unnecessary, as there was already the isset
on $_GET['id']
.
Could limit $ids
considered characters for the complexity but as a whole limiting previously at apache2 level in a more general way seem more appropriate if I ever do so.
The last entry of
$realIds
then containVIDEO_ID_50,VIDEO_ID_51
.