Skip to content

Commit cb8d88e

Browse files
committed
Add viewable whitelist based on browser-supported file extensions
1 parent 679a1a2 commit cb8d88e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

notebook/static/tree/js/notebooklist.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ define([
541541
};
542542

543543
NotebookList.ipynb_extensions = ['ipynb'];
544-
NotebookList.viewable_extensions = ['htm', 'html', 'xhtml', 'mht', 'mhtml'];
545544

546545
NotebookList.prototype._is_notebook = function(model) {
547546
return includes_extension(model.path, NotebookList.ipynb_extensions);
@@ -557,8 +556,15 @@ define([
557556
};
558557

559558
NotebookList.prototype._is_viewable = function(model) {
559+
var html_types = ['htm', 'html', 'xhtml', 'xml', 'mht', 'mhtml'];
560+
var media_extension = ['3gp', 'avi', 'mov', 'mp4', 'm4v', 'm4a', 'mp3', 'mkv', 'ogv', 'ogm', 'ogg', 'oga', 'webm', 'wav'];
561+
var image_type = ['bmp', 'gif', 'jpg', 'jpeg', 'png', 'webp'];
562+
var archive_type = ['zip', 'rar'];
563+
var other_type = ['txt', 'pdf', 'ico'];
564+
var office_types = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'];
565+
var viewable_extensions = [].concat(html_types, media_extension, image_type, archive_type, other_type, office_types);
560566
return model.mimetype === 'text/html'
561-
|| includes_extension(model.path, NotebookList.viewable_extensions);
567+
|| includes_extension(model.path, viewable_extensions);
562568
};
563569

564570
/**

0 commit comments

Comments
 (0)