Skip to content

Commit

Permalink
fix: add quote for ids processed in downloadAsZipAddFilesAction method (
Browse files Browse the repository at this point in the history
  • Loading branch information
lukmzig committed Jan 24, 2024
1 parent 8a1361c commit 363afef
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/Controller/Admin/Asset/AssetController.php
Expand Up @@ -2015,10 +2015,10 @@ public function downloadAsZipJobsAction(Request $request): JsonResponse
$userIds = $this->getAdminUser()->getRoles();
$userIds[] = $this->getAdminUser()->getId();
$conditionFilters[] = ' (
(select list from users_workspaces_asset where userId in (' . implode(',', $userIds) . ') and LOCATE(CONCAT(`path`, filename),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1
OR
(select list from users_workspaces_asset where userId in (' . implode(',', $userIds) . ') and LOCATE(cpath,CONCAT(`path`, filename))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1
)';
(select list from users_workspaces_asset where userId in (' . implode(',', $userIds) . ') and LOCATE(CONCAT(`path`, filename),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1
OR
(select list from users_workspaces_asset where userId in (' . implode(',', $userIds) . ') and LOCATE(cpath,CONCAT(`path`, filename))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1
)';
}

$condition = implode(' AND ', $conditionFilters);
Expand Down Expand Up @@ -2088,18 +2088,24 @@ public function downloadAsZipAddFilesAction(Request $request): JsonResponse

if (!empty($selectedIds)) {
$selectedIds = explode(',', $selectedIds);
$quotedSelectedIds = [];
foreach ($selectedIds as $selectedId) {
if ($selectedId) {
$quotedSelectedIds[] = $db->quote($selectedId);
}
}
//add a condition if id numbers are specified
$conditionFilters[] = 'id IN (' . implode(',', $selectedIds) . ')';
$conditionFilters[] = 'id IN (' . implode(',', $quotedSelectedIds) . ')';
}
$conditionFilters[] = "`type` != 'folder' AND `path` like " . $db->quote(Helper::escapeLike($parentPath) . '/%');
if (!$this->getAdminUser()->isAdmin()) {
$userIds = $this->getAdminUser()->getRoles();
$userIds[] = $this->getAdminUser()->getId();
$conditionFilters[] = ' (
(select list from users_workspaces_asset where userId in (' . implode(',', $userIds) . ') and LOCATE(CONCAT(`path`, filename),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1
OR
(select list from users_workspaces_asset where userId in (' . implode(',', $userIds) . ') and LOCATE(cpath,CONCAT(`path`, filename))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1
)';
(select list from users_workspaces_asset where userId in (' . implode(',', $userIds) . ') and LOCATE(CONCAT(`path`, filename),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1
OR
(select list from users_workspaces_asset where userId in (' . implode(',', $userIds) . ') and LOCATE(cpath,CONCAT(`path`, filename))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1
)';
}

$condition = implode(' AND ', $conditionFilters);
Expand Down

0 comments on commit 363afef

Please sign in to comment.