Skip to content

Commit 4e55230

Browse files
committed
fix(setChildrenOrder): Harden against problematic payloads
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 0e974a9 commit 4e55230

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/Db/TreeMapper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,12 +802,14 @@ public function setChildrenOrder(int $folderId, array $newChildrenOrder): void {
802802
if (!in_array($child, $newChildrenOrder, false)) {
803803
throw new ChildrenOrderValidationError('A child is missing: ' . $child['type'] . ':' . $child['id']);
804804
}
805-
if (!isset($child['id'], $child['type'])) {
805+
}
806+
foreach ($newChildrenOrder as $child) {
807+
if (!is_array($child) || !isset($child['id'], $child['type'])) {
806808
throw new ChildrenOrderValidationError('A child item is missing properties');
807809
}
808810
}
809811
if (count($newChildrenOrder) !== count($existingChildren)) {
810-
throw new ChildrenOrderValidationError('To many children');
812+
throw new ChildrenOrderValidationError('Too many children');
811813
}
812814

813815
$qb = $this->db->getQueryBuilder();

0 commit comments

Comments
 (0)