summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-01-22 15:37:49 +0100
committerGitHub <noreply@github.com>2018-01-22 15:37:49 +0100
commit520f2fd6ea3661d5d49517c7265dd8d7515036ac (patch)
tree8eddd6618b02ece30539a27d093317f42e329696
parent1194e4c2bd6da09c975935d9f139052cfff9091e (diff)
parent8703df323392f8aa11c1c232a04be49c44f090bf (diff)
downloadnextcloud-server-520f2fd6ea3661d5d49517c7265dd8d7515036ac.tar.gz
nextcloud-server-520f2fd6ea3661d5d49517c7265dd8d7515036ac.zip
Merge pull request #7986 from nextcloud/fix_7749
If the preview is size 0 it is invalid
-rw-r--r--lib/private/Preview/Generator.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index 60b7536d074..08f6b604eca 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -110,6 +110,11 @@ class Generator {
// Get the max preview and infer the max preview sizes from that
$maxPreview = $this->getMaxPreview($previewFolder, $file, $mimeType);
+ if ($maxPreview->getSize() === 0) {
+ $maxPreview->delete();
+ throw new NotFoundException('Max preview size 0, invalid!');
+ }
+
list($maxWidth, $maxHeight) = $this->getPreviewSize($maxPreview);
// If both width and heigth are -1 we just want the max preview
@@ -129,15 +134,20 @@ class Generator {
// Try to get a cached preview. Else generate (and store) one
try {
try {
- $file = $this->getCachedPreview($previewFolder, $width, $height, $crop, $maxPreview->getMimeType());
+ $preview = $this->getCachedPreview($previewFolder, $width, $height, $crop, $maxPreview->getMimeType());
} catch (NotFoundException $e) {
- $file = $this->generatePreview($previewFolder, $maxPreview, $width, $height, $crop, $maxWidth, $maxHeight);
+ $preview = $this->generatePreview($previewFolder, $maxPreview, $width, $height, $crop, $maxWidth, $maxHeight);
}
} catch (\InvalidArgumentException $e) {
throw new NotFoundException();
}
- return $file;
+ if ($preview->getSize() === 0) {
+ $preview->delete();
+ throw new NotFoundException('Cached preview size 0, invalid!');
+ }
+
+ return $preview;
}
/**