[Pkg-owncloud-commits] [owncloud] 22/34: Fix SVG icons

David Prévot taffit at moszumanska.debian.org
Thu Nov 13 19:37:13 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v6.0.6
in repository owncloud.

commit 979d2823b532446d6c5ef24717178f3533fda1c3
Author: Lukas Reschke <lukas at owncloud.com>
Date:   Thu Oct 16 12:13:16 2014 +0200

    Fix SVG icons
    
    FIXME: Ugly hack to prevent SVG of being returned if the SVG
    provider is not enabled.
    This is required because the preview system is designed in a
    bad way and relies on opt-in with asterisks (i.e. image/*)
    which will lead to the fact that a SVG will also match the image
    provider.
---
 apps/files_sharing/js/public.js |  2 +-
 lib/private/preview.php         | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 377be5a..c697f43 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -25,7 +25,7 @@ $(document).ready(function() {
 		};
 
 		var img = $('<img class="publicpreview">');
-		if (previewSupported === 'true' || mimetype.substr(0, mimetype.indexOf('/')) === 'image') {
+		if (previewSupported === 'true' || mimetype.substr(0, mimetype.indexOf('/')) === 'image' && mimetype !== 'image/svg+xml') {
 			img.attr('src', OC.filePath('files_sharing', 'ajax', 'publicpreview.php') + '?' + OC.buildQueryString(params));
 			img.appendTo('#imgframe');
 		} else if (mimetype.substr(0, mimetype.indexOf('/')) !== 'video') {
diff --git a/lib/private/preview.php b/lib/private/preview.php
index c2e67bf..4980c43 100755
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -660,6 +660,16 @@ class Preview {
 			self::initProviders();
 		}
 
+		// FIXME: Ugly hack to prevent SVG of being returned if the SVG
+		// provider is not enabled.
+		// This is required because the preview system is designed in a
+		// bad way and relies on opt-in with asterisks (i.e. image/*)
+		// which will lead to the fact that a SVG will also match the image
+		// provider.
+		if($mimetype === 'image/svg+xml' && !array_key_exists('/image\/svg\+xml/', self::$providers)) {
+			return false;
+		}
+
 		//remove last element because it has the mimetype *
 		foreach(self::$providers as $supportedMimetype => $provider) {
 			if(preg_match($supportedMimetype, $mimetype)) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list