mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(preview): Validate preview MIME type
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
This commit is contained in:
parent
6e06a87216
commit
419e64a320
1 changed files with 7 additions and 2 deletions
|
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue