From 2a1751ec30c2faf073d3592806d955be16e635ce Mon Sep 17 00:00:00 2001 From: alwaysjolley Date: Wed, 3 Jun 2020 04:56:38 -0400 Subject: [PATCH] fixing domain validation to account for 2-63 character length and correct character set --- lemur/dns_providers/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lemur/dns_providers/util.py b/lemur/dns_providers/util.py index cc8d9bb3..9aa10458 100644 --- a/lemur/dns_providers/util.py +++ b/lemur/dns_providers/util.py @@ -31,11 +31,11 @@ class DNSResolveError(DNSError): def is_valid_domain(domain): """Checks if a domain is syntactically valid and returns a bool""" - if len(domain) > 253: - return False if domain[-1] == ".": domain = domain[:-1] - fqdn_re = re.compile("(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(? 253: + return False + fqdn_re = re.compile("(?=^.{1,63}$)(^(?:[a-z0-9](?:-*[a-z0-9])+)$)", re.IGNORECASE) return all(fqdn_re.match(d) for d in domain.split("."))