Skip to content

Commit

Permalink
Validate JUPYTERHUB_SERVICE_URL port number
Browse files Browse the repository at this point in the history
  • Loading branch information
twalcari authored Jan 25, 2023
1 parent 8b013f7 commit ef2ac83
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nbviewer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ def default_endpoint(self):
if "JUPYTERHUB_SERVICE_URL" in os.environ:
url = urlparse(os.environ["JUPYTERHUB_SERVICE_URL"])
default_host, default_port = url.hostname, url.port

if default_port < 1 or default_port > 65535:
self.log.error("Received invalid port number %d through JUPYTERHUB_SERVICE_URL. "
"Defaulting to 5000 instead.")
default_port = 5000
else:
default_host, default_port = "0.0.0.0", 5000
return {"host": default_host, "port": default_port}
Expand Down

0 comments on commit ef2ac83

Please sign in to comment.