Skip to content

Commit e5b0b34

Browse files
author
Matthew Fisher
committed
fix(controller): allow labels with trailing numbers
as per RFC 1123, domain labels are allowed a trailing number.
1 parent a716eed commit e5b0b34

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

controller/api/serializers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ def validate_domain(self, value):
251251
allowed = re.compile("^(?!-)[a-z0-9-]{1,63}(?<!-)$", re.IGNORECASE)
252252
for label in labels:
253253
match = allowed.match(label)
254-
if not match or '--' in label or label[-1].isdigit() or label.isdigit():
254+
if not match or '--' in label or label.isdigit() or \
255+
len(labels) == 1 and any(char.isdigit() for char in label):
255256
raise serializers.ValidationError('Hostname does not look valid.')
256257
if models.Domain.objects.filter(domain=value).exists():
257258
raise serializers.ValidationError(

controller/api/tests/test_domain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def test_manage_domain(self):
5454
'domain',
5555
'not.too.loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong',
5656
'3com.com',
57+
'w3.example.com',
5758
'MYDOMAIN.NET',
5859
]
5960
for domain in test_domains:

0 commit comments

Comments
 (0)