diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-09-19 13:35:21 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-09-22 16:09:08 +0200 |
commit | ca3447fcdea878ade24caed4ad300697fc132d08 (patch) | |
tree | 2749ec20587207a007ac35e76d5d1d48712b5606 /lib/private/preview | |
parent | 831d34f084e4c2f6b13303f58e12a9f96eb10a74 (diff) | |
download | nextcloud-server-ca3447fcdea878ade24caed4ad300697fc132d08.tar.gz nextcloud-server-ca3447fcdea878ade24caed4ad300697fc132d08.zip |
Add a configuration switch for enabled preview mimetypes
Diffstat (limited to 'lib/private/preview')
-rw-r--r-- | lib/private/preview/svg.php | 5 | ||||
-rw-r--r-- | lib/private/preview/unknown.php | 49 |
2 files changed, 5 insertions, 49 deletions
diff --git a/lib/private/preview/svg.php b/lib/private/preview/svg.php index 82ef3cdebf6..0b5dbc9716f 100644 --- a/lib/private/preview/svg.php +++ b/lib/private/preview/svg.php @@ -31,6 +31,11 @@ if (extension_loaded('imagick')) { $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content; } + // Do not parse SVG files with references + if(stripos($content, 'xlink:href') !== false) { + return false; + } + $svg->readImageBlob($content); $svg->setImageFormat('png32'); } catch (\Exception $e) { diff --git a/lib/private/preview/unknown.php b/lib/private/preview/unknown.php deleted file mode 100644 index 2d3b5c5655e..00000000000 --- a/lib/private/preview/unknown.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Copyright (c) 2013 Frank Karlitschek frank@owncloud.org - * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ -namespace OC\Preview; - -class Unknown extends Provider { - - public function getMimeType() { - return '/.*/'; - } - - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $mimetype = $fileview->getMimeType($path); - - $path = \OC_Helper::mimetypeIcon($mimetype); - $path = \OC::$SERVERROOT . substr($path, strlen(\OC::$WEBROOT)); - - $svgPath = substr_replace($path, 'svg', -3); - - if (extension_loaded('imagick') && file_exists($svgPath) && count(@\Imagick::queryFormats("SVG")) === 1) { - - // http://www.php.net/manual/de/imagick.setresolution.php#85284 - $svg = new \Imagick(); - $svg->readImage($svgPath); - $res = $svg->getImageResolution(); - $x_ratio = $res['x'] / $svg->getImageWidth(); - $y_ratio = $res['y'] / $svg->getImageHeight(); - $svg->removeImage(); - $svg->setResolution($maxX * $x_ratio, $maxY * $y_ratio); - $svg->setBackgroundColor(new \ImagickPixel('transparent')); - $svg->readImage($svgPath); - $svg->setImageFormat('png32'); - - $image = new \OC_Image(); - $image->loadFromData($svg); - } else { - $image = new \OC_Image($path); - } - - return $image; - } -} - -\OC\Preview::registerProvider('OC\Preview\Unknown'); |