Pārlūkot izejas kodu

HUE-4645 [core] Disable inline display of SVG files

Enrico Berti 9 gadi atpakaļ
vecāks
revīzija
40281e5

+ 1 - 1
apps/filebrowser/src/filebrowser/templates/display.mako

@@ -165,7 +165,7 @@ ${ fb_components.menubar() }
     $.getJSON(_baseUrl, params, function (data) {
       var _html = "";
 
-      if (data.view.contents != null) {
+      if (data.view.contents) {
         var chunks = getChunks(startPage, endPage, data.view)
         for (var i = startPage; i <= endPage; i++) {
           pages[i] = chunks.shift();

+ 5 - 2
apps/filebrowser/src/filebrowser/views.py

@@ -84,6 +84,9 @@ INLINE_DISPLAY_MIMETYPE = re.compile('video/|image/|audio/|application/pdf|appli
                                      'application/vnd\.ms|'
                                      'application/vnd\.openxmlformats')
 
+INLINE_DISPLAY_MIMETYPE_EXCEPTIONS = re.compile('image/svg\+xml')
+
+
 logger = logging.getLogger(__name__)
 
 
@@ -554,8 +557,8 @@ def display(request, path):
     # display inline files just if it's not an ajax request
     if not request.is_ajax():
       mimetype = mimetypes.guess_type(path)[0]
-
-      if mimetype is not None and INLINE_DISPLAY_MIMETYPE.search(mimetype):
+      print mimetype
+      if mimetype is not None and INLINE_DISPLAY_MIMETYPE.search(mimetype) and INLINE_DISPLAY_MIMETYPE_EXCEPTIONS.search(mimetype) is None:
         return redirect(reverse('filebrowser.views.download', args=[path]) + '?disposition=inline')
 
     stats = request.fs.stats(path)