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.

Conflicts:
	lib/private/preview.php
This commit is contained in:
Lukas Reschke 2014-10-16 12:13:16 +02:00
parent 756f64d728
commit 9cfbf7ed1c
2 changed files with 14 additions and 3 deletions

View File

@ -85,7 +85,7 @@ OCA.Sharing.PublicApp = {
};
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') {

View File

@ -814,8 +814,19 @@ class Preview {
self::initProviders();
}
foreach (self::$providers as $supportedMimeType => $provider) {
if (preg_match($supportedMimeType, $mimeType)) {
// 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)) {
return true;
}
}