From d5fc516b510f51994b7c9704ea672bb7cbae3a72 Mon Sep 17 00:00:00 2001 From: Markus Koetter Date: Fri, 30 Sep 2022 10:21:44 +0200 Subject: [PATCH] ZoneNameValidator - allow "localhost." as domain index by 1 skips the leading dot tld_re = ( r"\." # dot https://github.com/django/django/blob/ae509f8f0804dea0eea89e27329014616c9d4cc0/django/core/validators.py#L85 --- src/conftest.py | 2 +- src/dino/zoneeditor/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conftest.py b/src/conftest.py index 860fcdb..d22b1ed 100644 --- a/src/conftest.py +++ b/src/conftest.py @@ -175,7 +175,7 @@ def mock_pdns_get_zones(mocker): rval = [ 'example.com.', 'example.org.', - ] + [f'example{i}.org' for i in range(500)] + ] + [f'example{i}.org' for i in range(500)] + ['localhost.'] return mocker.patch('dino.pdns_api.pdns.get_zones', return_value=rval) diff --git a/src/dino/zoneeditor/views.py b/src/dino/zoneeditor/views.py index 80adc24..d16b87f 100644 --- a/src/dino/zoneeditor/views.py +++ b/src/dino/zoneeditor/views.py @@ -78,7 +78,7 @@ class ZoneNameValidator(RegexValidator): hostname_re = r'[_a-z' + URLValidator.ul + r'0-9](?:[a-z' + URLValidator.ul + r'0-9-]{0,61}[a-z' + URLValidator.ul + r'0-9])?' # identical to URLValidator.domain_re, except for leading underscroes domain_re = r'(?:\.(?!-)[_a-z' + URLValidator.ul + r'0-9-]{1,63}(?