From 569183e9a4767160f349d5fbead8ffde0c64c792 Mon Sep 17 00:00:00 2001 From: Ciaran Langton Date: Sun, 10 Mar 2019 21:51:29 +0000 Subject: [PATCH 01/11] Fix incorrect MIME type for JavaScript --- jupyter_server/serverapp.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index c94e7793cf..3f1f810a65 100755 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -1485,10 +1485,12 @@ def init_server_extensions(self): def init_mime_overrides(self): # On some Windows machines, an application has registered an incorrect - # mimetype for CSS in the registry. Tornado uses this when serving - # .css files, causing browsers to reject the stylesheet. We know the - # mimetype always needs to be text/css, so we override it here. + # mimetype for CSS and JavaScript in the registry. + # Tornado uses this when serving .css files, causing browsers to reject the stylesheet. + # We know the mimetype always needs to be text/css for css + # and application/javascript for JS, so we override it here. mimetypes.add_type('text/css', '.css') + mimetypes.add_type('application/javascript', '.js') def shutdown_no_activity(self): """Shutdown server on timeout when there are no kernels or terminals.""" From b6550ebcf72bd89feadd81c395abf134165d9f7a Mon Sep 17 00:00:00 2001 From: Ciaran Langton Date: Sun, 10 Mar 2019 22:13:22 +0000 Subject: [PATCH 02/11] Fix comment --- jupyter_server/serverapp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 3f1f810a65..47e8e1793a 100755 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -1486,8 +1486,8 @@ def init_server_extensions(self): def init_mime_overrides(self): # On some Windows machines, an application has registered an incorrect # mimetype for CSS and JavaScript in the registry. - # Tornado uses this when serving .css files, causing browsers to reject the stylesheet. - # We know the mimetype always needs to be text/css for css + # 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. mimetypes.add_type('text/css', '.css') mimetypes.add_type('application/javascript', '.js') From d8c45735ba4663730b3e40499f760fbf960161ca Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 28 Mar 2019 14:56:13 +0100 Subject: [PATCH 03/11] explicitly ignore windows registry for mimetypes since it has proven untrustworthy for many users --- jupyter_server/serverapp.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 47e8e1793a..1f248ebd09 100755 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -1484,11 +1484,16 @@ def init_server_extensions(self): 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') From 20940263716eb6c1eb2357f79eec4f8e027ffcbf Mon Sep 17 00:00:00 2001 From: Ivan Ogasawara Date: Fri, 29 Mar 2019 20:05:59 -0400 Subject: [PATCH 04/11] Changed the default protocol Applied suggestion from review Fixed hasattr issue --- jupyter_server/serverapp.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 1f248ebd09..b440769fb1 100755 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -1296,7 +1296,11 @@ def init_webapp(self): # SSL may be missing, so only import it if it's to be used import ssl # Disable SSLv3 by default, since its use is discouraged. - ssl_options.setdefault('ssl_version', ssl.PROTOCOL_TLSv1) + _ssl_protocol = ( + ssl.PROTOCOL_TLS if hasattr(ssl, 'PROTOCOL_TLS') + else ssl.PROTOCOL_SSLv23 + ) + ssl_options.setdefault('ssl_version', _ssl_protocol) if ssl_options.get('ca_certs', False): ssl_options.setdefault('cert_reqs', ssl.CERT_REQUIRED) From ff3017fdab9f95d03cfe98cf9b2e03545fe564fd Mon Sep 17 00:00:00 2001 From: Ivan Ogasawara Date: Wed, 3 Apr 2019 10:36:37 -0400 Subject: [PATCH 05/11] Improve code, add docstring --- jupyter_server/serverapp.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index b440769fb1..f227714241 100755 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -1295,12 +1295,12 @@ def init_webapp(self): else: # SSL may be missing, so only import it if it's to be used import ssl - # Disable SSLv3 by default, since its use is discouraged. - _ssl_protocol = ( - ssl.PROTOCOL_TLS if hasattr(ssl, 'PROTOCOL_TLS') - else ssl.PROTOCOL_SSLv23 + # PROTOCOL_TLS selects the highest ssl/tls protocol version that both the client and + # server support. When PROTOCOL_TLS is not available use PROTOCOL_SSLv23 + ssl_options.setdefault( + 'ssl_version', + getattr('ssl', 'PROTOCOL_TLS', ssl.PROTOCOL_SSLv23) ) - ssl_options.setdefault('ssl_version', _ssl_protocol) if ssl_options.get('ca_certs', False): ssl_options.setdefault('cert_reqs', ssl.CERT_REQUIRED) From b4bcb888f0f9a9ecd0bedbdc536f363725ed93d7 Mon Sep 17 00:00:00 2001 From: Ivan Ogasawara Date: Wed, 3 Apr 2019 12:41:10 -0400 Subject: [PATCH 06/11] Fixed small issue and added more information about PROTOCOL_TLS --- jupyter_server/serverapp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index f227714241..e9dc8e7f08 100755 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -1296,10 +1296,11 @@ def init_webapp(self): # SSL may be missing, so only import it if it's to be used import ssl # PROTOCOL_TLS selects the highest ssl/tls protocol version that both the client and - # server support. When PROTOCOL_TLS is not available use PROTOCOL_SSLv23 + # server support. When PROTOCOL_TLS is not available use PROTOCOL_SSLv23. + # PROTOCOL_TLS is new in version 2.7.13, 3.5.3 and 3.6 ssl_options.setdefault( 'ssl_version', - getattr('ssl', 'PROTOCOL_TLS', ssl.PROTOCOL_SSLv23) + getattr(ssl, 'PROTOCOL_TLS', ssl.PROTOCOL_SSLv23) ) if ssl_options.get('ca_certs', False): ssl_options.setdefault('cert_reqs', ssl.CERT_REQUIRED) From d2adacb4128f7252c30417022848e9c3467a8522 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Wed, 12 Jun 2019 16:51:42 +0200 Subject: [PATCH 07/11] Added control channel to ZMQChannelsHandler From 8b74f013bf1c33590dbfa0ad9296c9af27bcdadb Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Mon, 8 Jul 2019 11:15:39 +0200 Subject: [PATCH 08/11] Bumped the required version of jupyter_client From d62f738f3ad1a8f25764e4bf67eac7004c8e144b Mon Sep 17 00:00:00 2001 From: Ashton Reimer Date: Thu, 13 Jun 2019 15:36:45 -0700 Subject: [PATCH 09/11] bfix: shutdown_server returns True when pid exists `check_pid` returns `True` if the PID for a notebook server still exists. Therefore, the `if check_pid(pid):` statements on lines 424 and 437 evaluate to `True` even though the notebook server is still running. This commit simply adds a `not` to each line: `if not check_pid(pid):` so that the conditional only evaluates to `True` if `check_pid` returns `False`, which happens when the notebook server has shutdown, as expected. --- jupyter_server/serverapp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index e9dc8e7f08..add26d69f8 100755 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -398,7 +398,7 @@ def shutdown_server(server_info, timeout=5, log=None): # Poll to see if it shut down. for _ in range(timeout*10): - if check_pid(pid): + if not check_pid(pid): if log: log.debug("Server PID %s is gone", pid) return True time.sleep(0.1) @@ -411,7 +411,7 @@ def shutdown_server(server_info, timeout=5, log=None): # Poll to see if it shut down. for _ in range(timeout * 10): - if check_pid(pid): + if not check_pid(pid): if log: log.debug("Server PID %s is gone", pid) return True time.sleep(0.1) From d1ec4bc2b23eb66821ccf337f67d2b7f4af8ed3f Mon Sep 17 00:00:00 2001 From: Tom Jarosz Date: Mon, 16 Sep 2019 09:52:17 -0700 Subject: [PATCH 10/11] Added decorator Added decorator `@gen.coroutine` to `FileHandler.get()` --- jupyter_server/files/handlers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jupyter_server/files/handlers.py b/jupyter_server/files/handlers.py index d6bc5e4a8a..b2e993a0a4 100644 --- a/jupyter_server/files/handlers.py +++ b/jupyter_server/files/handlers.py @@ -34,6 +34,7 @@ def head(self, path): self.get(path, include_body=False) @web.authenticated + @gen.coroutine def get(self, path, include_body=True): cm = self.contents_manager From 21fc939bb2cc523782844c32ead8d0860fdf07f9 Mon Sep 17 00:00:00 2001 From: Tom Jarosz Date: Mon, 16 Sep 2019 10:03:00 -0700 Subject: [PATCH 11/11] Import `gen`