summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Preview.php6
-rw-r--r--lib/private/PreviewNotAvailableException.php27
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/private/Preview.php b/lib/private/Preview.php
index 28579ef2c86..ccaec738caf 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;
diff --git a/lib/private/PreviewNotAvailableException.php b/lib/private/PreviewNotAvailableException.php
new file mode 100644
index 00000000000..7d92e860629
--- /dev/null
+++ b/lib/private/PreviewNotAvailableException.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Morris Jobke <hey@morrisjobke.de>
+ *
+ * @author Morris Jobke <hey@morrisjobke.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC;
+
+class PreviewNotAvailableException extends \Exception {
+}