Skip to content

Commit 35b8a14

Browse files
committed
fix dns regex: underscores are allowed in domain names even though they are not allowed in hostnames
1 parent d0423af commit 35b8a14

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

management/dns_update.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
from utils import shell, load_env_vars_from_file, safe_domain_name, sort_domains
1414

1515
# From https://stackoverflow.com/questions/3026957/how-to-validate-a-domain-name-using-regex-php/16491074#16491074
16-
# Thanks to Onur Yıldırım
17-
# This regular expression matches domain names according to RFCs, it also accepts fqdn with an leading dot
18-
DOMAIN_RE = "^(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}(\.?)$"
16+
# This regular expression matches domain names according to RFCs, it also accepts fqdn with an leading dot,
17+
# as well as underscores which are allowed in domain names but not hostnames (i.e. allowed in
18+
# DNS but not in URLs), which are common in certain record types like for DKIM.
19+
DOMAIN_RE = "^(?!\-)(?:[a-zA-Z\d\-_]{0,62}[a-zA-Z\d_]\.){1,126}(?!\d+)[a-zA-Z\d_]{1,63}(\.?)$"
1920

2021
def get_dns_domains(env):
2122
# Add all domain names in use by email users and mail aliases and ensure

0 commit comments

Comments
 (0)