Skip to content

Commit

Permalink
Merge pull request #1038 from twalcari/patch-1
Browse files Browse the repository at this point in the history
Validate JUPYTERHUB_SERVICE_URL port number
  • Loading branch information
minrk authored Jan 27, 2023
2 parents 8b013f7 + 1f2dd32 commit 51eff7b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nbviewer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,13 @@ 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 51eff7b

Please sign in to comment.