Skip to content

Commit ef2ac83

Browse files
authored
Validate JUPYTERHUB_SERVICE_URL port number
Fixes jupyter/docker-stacks#1862
1 parent 8b013f7 commit ef2ac83

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

nbviewer/app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,11 @@ def default_endpoint(self):
458458
if "JUPYTERHUB_SERVICE_URL" in os.environ:
459459
url = urlparse(os.environ["JUPYTERHUB_SERVICE_URL"])
460460
default_host, default_port = url.hostname, url.port
461+
462+
if default_port < 1 or default_port > 65535:
463+
self.log.error("Received invalid port number %d through JUPYTERHUB_SERVICE_URL. "
464+
"Defaulting to 5000 instead.")
465+
default_port = 5000
461466
else:
462467
default_host, default_port = "0.0.0.0", 5000
463468
return {"host": default_host, "port": default_port}

0 commit comments

Comments
 (0)