Allow underscore in hostname

This commit is contained in:
chhsiao90 2016-12-30 21:03:22 +08:00
parent 973406f327
commit a5f1215eb2
2 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import re
_label_valid = re.compile(b"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
# Allow underscore in host name
_label_valid = re.compile(b"(?!-)[A-Z\d\-_]{1,63}(?<!-)$", re.IGNORECASE)
def is_valid_host(host: bytes) -> bool:

View File

@ -8,3 +8,5 @@ def test_is_valid_host():
assert check.is_valid_host(b"one.two")
assert not check.is_valid_host(b"one" * 255)
assert check.is_valid_host(b"one.two.")
# Allow underscore
assert check.is_valid_host(b"one_two")