diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-01-24 16:40:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-24 16:40:44 +0100 |
commit | a0f62b71c8ebb8e7bfc26c88cfac469b910996da (patch) | |
tree | 54e9d57a6178006b3aa4b746a3ab73d802264074 | |
parent | 1a21524f6f9624178bf5b95cfcab1847ab394424 (diff) | |
parent | f259e1cb8c03369e454810c5436e2f6b4444fa8d (diff) | |
download | nextcloud-server-a0f62b71c8ebb8e7bfc26c88cfac469b910996da.tar.gz nextcloud-server-a0f62b71c8ebb8e7bfc26c88cfac469b910996da.zip |
Merge pull request #8030 from nextcloud/7986_12
[stable13] If the preview is size 0 it is invalid
-rw-r--r-- | lib/private/Preview/Generator.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index 448a7a57580..e28e436b1a0 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; } /** |