diff --git a/webssh/utils.py b/webssh/utils.py index f4611e0..b0aa15a 100644 --- a/webssh/utils.py +++ b/webssh/utils.py @@ -1,13 +1,16 @@ import ipaddress import re - try: from types import UnicodeType except ImportError: UnicodeType = str +numeric = re.compile(r'[0-9]+$') +allowed = re.compile(r'(?!-)[a-z0-9-]{1,63}(? 253: return False - labels = hostname.split(".") + labels = hostname.split('.') # the TLD must be not all-numeric - if re.match(r"[0-9]+$", labels[-1]): + if numeric.match(labels[-1]): return False - allowed = re.compile(r"(?!-)[a-z0-9-]{1,63}(?