aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorScott Dutton <scott@exussum.co.uk>2020-04-12 16:38:59 +0100
committerMorris Jobke <hey@morrisjobke.de>2020-08-13 22:50:38 +0200
commitb12a390220a0a38ec18557b52c2eec7cf25dfc49 (patch)
tree1e4471e468b50497737dcb97c2bb64f39786d015 /lib
parente9f5c7f649b923ec45d7a37eb24369e11727ccbf (diff)
downloadnextcloud-server-b12a390220a0a38ec18557b52c2eec7cf25dfc49.tar.gz
nextcloud-server-b12a390220a0a38ec18557b52c2eec7cf25dfc49.zip
Always try and show pre rendered preview
Currently if the following situation happens Server generates preview Server has command removed which allows a preview to be shown Client asks for preview, gets a 404 error when preview exists (Mime checked before preview) This happens more often with documents, or video as the commands are not native PHP, they require a binary on the server. After the fix the following would happen Server generates preview Server has command removed which allows a preview to be shown Client asks for preview, gets preview which has been generated (Mime checked after preview) This would also allow offline generation (for example a docker image containing the extra binaries), allowing a reduction in attack surface of the instance serving the preview data. Signed-off-by: Scott Dutton <scott@exussum.co.uk>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Preview/Generator.php9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index e47a7e5927c..d55aa1cb287 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -126,9 +126,6 @@ class Generator {
if ($mimeType === null) {
$mimeType = $file->getMimeType();
}
- if (!$this->previewManager->isMimeSupported($mimeType)) {
- throw new NotFoundException();
- }
$previewFolder = $this->getPreviewFolder($file);
@@ -155,7 +152,7 @@ class Generator {
$crop = $specification['crop'] ?? false;
$mode = $specification['mode'] ?? IPreview::MODE_FILL;
- // If both width and heigth are -1 we just want the max preview
+ // If both width and height are -1 we just want the max preview
if ($width === -1 && $height === -1) {
$width = $maxWidth;
$height = $maxHeight;
@@ -176,6 +173,10 @@ class Generator {
try {
$preview = $this->getCachedPreview($previewFolder, $width, $height, $crop, $maxPreview->getMimeType(), $previewVersion);
} catch (NotFoundException $e) {
+ if (!$this->previewManager->isMimeSupported($mimeType)) {
+ throw new NotFoundException();
+ }
+
if ($maxPreviewImage === null) {
$maxPreviewImage = $this->helper->getImage($maxPreview);
}