From eb9d3183b59d56c16794ac144bf23a272395c3cf Mon Sep 17 00:00:00 2001 From: Oli <932481+tb-killa@users.noreply.github.com> Date: Tue, 21 May 2019 09:16:29 +0200 Subject: [PATCH] Change DNSValidator-Regex This Change the Regex for DNSValidator to be valid as per RFC 1123. Originally, RFC 952 specified that hostname segments could not start with a digit. From: http://en.wikipedia.org/wiki/Hostname `` The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. `` --- netbox/ipam/validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/ipam/validators.py b/netbox/ipam/validators.py index 6669b7ec5..e2e33a1eb 100644 --- a/netbox/ipam/validators.py +++ b/netbox/ipam/validators.py @@ -2,7 +2,7 @@ from django.core.validators import RegexValidator DNSValidator = RegexValidator( - regex='^[0-9A-Za-z.-]+$', + regex='^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$', message='Only alphanumeric characters, hyphens, and periods are allowed in DNS names', code='invalid' )