fix(preview): Validate preview MIME type

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
This commit is contained in:
Git'Fellow 2026-03-08 18:48:13 +01:00 committed by backportbot[bot]
parent 6e06a87216
commit 419e64a320

View file

@ -542,6 +542,10 @@ class Generator {
self::unguardWithSemaphore($sem);
}
if (!$preview->valid() || $preview->dataMimeType() === null) {
throw new \InvalidArgumentException('Preview generation failed: invalid or null MIME type');
}
$previewEntry = new Preview();
$previewEntry->generateId();
$previewEntry->setFileId($file->getId());
@ -556,12 +560,13 @@ class Generator {
$previewEntry->setMimeType($preview->dataMimeType());
$previewEntry->setEtag($file->getEtag());
$previewEntry->setMtime((new \DateTime())->getTimestamp());
if ($cacheResult) {
$previewEntry = $this->savePreview($previewEntry, $preview);
return new PreviewFile($previewEntry, $this->storageFactory, $this->previewMapper);
} else {
return new InMemoryFile($previewEntry->getName(), $preview->data());
}
return new InMemoryFile($previewEntry->getName(), $preview->data());
}
/**