summaryrefslogtreecommitdiffstats
path: root/lib/private/Preview.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-09-09 10:58:52 +0200
committerMorris Jobke <hey@morrisjobke.de>2016-09-09 13:53:06 +0200
commitf56ae37e8fe31afb109889816273c21704361f15 (patch)
tree8fd7cd8dd480d36d1e41184b3a1c4cc43712d7fe /lib/private/Preview.php
parentf5aafdc89789623e72f9a05ecc2629ed2894668b (diff)
downloadnextcloud-server-f56ae37e8fe31afb109889816273c21704361f15.tar.gz
nextcloud-server-f56ae37e8fe31afb109889816273c21704361f15.zip
Opening the trashbin causes errors in log for files without preview
* put a file without a generated preview in the trashbin (e.g. a *.docx file) * open the trashbin * following errors will show up in the nextcloud.log: - filesize(): stat failed for ... - fopen(...): failed to open stream: No such file or directory at ... - fread() expects parameter 1 to be resource, boolean given at ... - fclose() expects parameter 1 to be resource, boolean given at ... - imagecreatefromstring(): Empty string or invalid image at ... This is because the preview code tries to load an SVG image, which is obviously only text. The fix simply handles this before the loading happens and the web UI keeps showing the default mimetype icon.
Diffstat (limited to 'lib/private/Preview.php')
-rw-r--r--lib/private/Preview.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/private/Preview.php b/lib/private/Preview.php
index 67838a8d4a3..9c6a7b54988 100644
--- a/lib/private/Preview.php
+++ b/lib/private/Preview.php
@@ -791,6 +791,7 @@ class Preview {
* @param null|string $mimeTypeForHeaders the media type to use when sending back the reply
*
* @throws NotFoundException
+ * @throws PreviewNotAvailableException
*/
public function showPreview($mimeTypeForHeaders = null) {
// Check if file is valid
@@ -1172,6 +1173,7 @@ class Preview {
/**
* Defines the media icon, for the media type of the original file, as the preview
+ * @throws PreviewNotAvailableException
*/
private function getMimeIcon() {
$image = new \OC_Image();
@@ -1181,6 +1183,10 @@ class Preview {
} else {
$mimeIconServerPath = str_replace(\OC::$WEBROOT, \OC::$SERVERROOT, $mimeIconWebPath);
}
+ // we can't load SVGs into an image
+ if (substr($mimeIconWebPath, -4) === '.svg') {
+ throw new PreviewNotAvailableException('SVG mimetype cannot be rendered');
+ }
$image->loadFromFile($mimeIconServerPath);
$this->preview = $image;