Allow underscores in broadlink hostnames (#35791)
* Allow underscores in hostnames * Ignore case
This commit is contained in:
parent
12ec476821
commit
2b38df2766
1 changed files with 2 additions and 2 deletions
|
@ -31,12 +31,12 @@ def data_packet(value):
|
||||||
|
|
||||||
def hostname(value):
|
def hostname(value):
|
||||||
"""Validate a hostname."""
|
"""Validate a hostname."""
|
||||||
host = str(value).lower()
|
host = str(value)
|
||||||
if len(host) > 253:
|
if len(host) > 253:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if host[-1] == ".":
|
if host[-1] == ".":
|
||||||
host = host[:-1]
|
host = host[:-1]
|
||||||
allowed = re.compile(r"(?!-)[a-z\d-]{1,63}(?<!-)$")
|
allowed = re.compile(r"(?![_-])[a-z\d_-]{1,63}(?<![_-])$", flags=re.IGNORECASE)
|
||||||
if not all(allowed.match(elem) for elem in host.split(".")):
|
if not all(allowed.match(elem) for elem in host.split(".")):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
return host
|
return host
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue