multipreview: check params

cap
Varun Patil 2022-12-08 13:37:55 -08:00
parent 9d619d5691
commit 1204982c0b
1 changed files with 25 additions and 17 deletions

View File

@ -111,17 +111,24 @@ class ImageController extends ApiBase
header('Cache-Control: max-age='. 7 * 3600 * 24 .', private');
foreach ($files as $bodyFile) {
if (!isset($bodyFile['reqid']) || !isset($bodyFile['fileid']) || !isset($bodyFile['x']) || !isset($bodyFile['y']) || !isset($bodyFile['a'])) {
continue;
}
$reqid = $bodyFile['reqid'];
$fileid = (int) $bodyFile['fileid'];
$x = (int) $bodyFile['x'];
$y = (int) $bodyFile['y'];
$a = '1' === $bodyFile['a'];
if ($fileid <= 0 || $x <= 0 || $y <= 0) {
continue;
}
$file = $this->getUserFile($fileid);
if (!$file) {
continue;
}
try {
// Make sure max preview exists
$fileId = (string) $file->getId();
$folder = $previewRoot->getFolder($fileId);
@ -139,7 +146,6 @@ class ImageController extends ApiBase
}
// Add this preview to the response
try {
$preview = $previewManager->getPreview($file, $x, $y, !$a, 'fill');
$content = $preview->getContent();
if (empty($content)) {
@ -154,6 +160,8 @@ class ImageController extends ApiBase
echo "\n";
echo $content;
flush();
} catch (\OCP\Files\NotFoundException $e) {
continue;
} catch (\Exception $e) {
continue;
}