From 2fabe50c60d3bafb2f91acfc6c5d9ab5628bef7f Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 28 Mar 2019 14:56:13 +0100 Subject: [PATCH] explicitly ignore windows registry for mimetypes since it has proven untrustworthy for many users --- notebook/notebookapp.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 6607dc1a3..e1f149e20 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -1618,11 +1618,16 @@ class NotebookApp(JupyterApp): exc_info=True) def init_mime_overrides(self): - # On some Windows machines, an application has registered an incorrect - # mimetype for CSS and JavaScript in the registry. + # On some Windows machines, an application has registered incorrect + # mimetypes in the registry. # Tornado uses this when serving .css and .js files, causing browsers to # reject these files. We know the mimetype always needs to be text/css for css - # and application/javascript for JS, so we override it here. + # and application/javascript for JS, so we override it here + # and explicitly tell the mimetypes to not trust the Windows registry + if os.name == 'nt': + # do not trust windows registry, which regularly has bad info + mimetypes.init(files=[]) + # ensure css, js are correct, which are required for pages to function mimetypes.add_type('text/css', '.css') mimetypes.add_type('application/javascript', '.js')