mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 15:03:02 +00:00
ensure user subdomains are valid
escape with `_` instead of `%`. This is not technically rigorous, as collisions are possible (users foo_40 and foo@ have the same domain) and other domain restrictions are not applied (length, starting characters, etc.). Username normalization can be used to apply stricter, more rigorous structure.
This commit is contained in:
@@ -295,15 +295,17 @@ class User:
|
||||
@property
|
||||
def domain(self):
|
||||
"""Get the domain for my server."""
|
||||
# FIXME: escaped_name probably isn't escaped enough in general for a domain fragment
|
||||
return self.escaped_name + '.' + self.settings['domain']
|
||||
# use underscore as escape char for domains
|
||||
return quote(self.name).replace('%', '_').lower() + '.' + self.settings['domain']
|
||||
|
||||
@property
|
||||
def host(self):
|
||||
"""Get the *host* for my server (proto://domain[:port])"""
|
||||
# FIXME: escaped_name probably isn't escaped enough in general for a domain fragment
|
||||
parsed = urlparse(self.settings['subdomain_host'])
|
||||
h = '%s://%s.%s' % (parsed.scheme, self.escaped_name, parsed.netloc)
|
||||
h = '%s://%s' % (parsed.scheme, self.domain)
|
||||
if parsed.port:
|
||||
h += ':%i' % parsed.port
|
||||
return h
|
||||
|
||||
@property
|
||||
|
Reference in New Issue
Block a user