Merge pull request #1905 from chhsiao90/allow-underscore-hostname

Allow underscore in hostname
This commit is contained in:
Maximilian Hils 2016-12-30 21:19:25 +01:00 committed by GitHub
commit e83083b64e
2 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import re 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: 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 check.is_valid_host(b"one.two")
assert not check.is_valid_host(b"one" * 255) assert not check.is_valid_host(b"one" * 255)
assert check.is_valid_host(b"one.two.") assert check.is_valid_host(b"one.two.")
# Allow underscore
assert check.is_valid_host(b"one_two")