From cf7a16c70fbb979b4407dc71ef73c2691ad18c8b Mon Sep 17 00:00:00 2001 From: Garrett Hayes <60194316+pr0fg@users.noreply.github.com> Date: Sun, 4 Oct 2020 21:03:07 -0400 Subject: [PATCH] Updated domain validator coverage Updated domain validator to support domains that start with an underscore. These domains are quite common in the wild. For example: _jabber._tcp.gmail.com _sip._udp.apnic.net See RFC 2181, section 11, "Name syntax" and RFC 1034, section 3.5 "Preferred name syntax" for more info. --- validators/domain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validators/domain.py b/validators/domain.py index 1c1ce232..258f3b7f 100644 --- a/validators/domain.py +++ b/validators/domain.py @@ -11,7 +11,7 @@ text_type = unicode pattern = re.compile( - r'^(?:[a-zA-Z0-9]' # First character of the domain + r'^(?:[a-zA-Z0-9_]' # First character of the domain r'(?:[a-zA-Z0-9-_]{0,61}[A-Za-z0-9])?\.)' # Sub domain + hostname r'+[A-Za-z0-9][A-Za-z0-9-_]{0,61}' # First 61 characters of the gTLD r'[A-Za-z]$' # Last character of the gTLD