Преглед на файлове

fix(api): allow punycode TLDs

Peter Thomassen преди 4 години
родител
ревизия
8cf0d7019f
променени са 3 файла, в които са добавени 7 реда и са изтрити 2 реда
  1. 2 2
      api/desecapi/models.py
  2. 1 0
      api/desecapi/tests/test_domains.py
  3. 4 0
      docs/dns/domains.rst

+ 2 - 2
api/desecapi/models.py

@@ -204,9 +204,9 @@ class Token(ExportModelOperationsMixin('Token'), rest_framework.authtoken.models
 validate_domain_name = [
     validate_lower,
     RegexValidator(
-        regex=r'^(([a-z0-9_-]{1,63})\.)*[a-z]{1,63}$',
+        regex=r'^(([a-z0-9_-]{1,63})\.)*[a-z0-9-]{1,63}$',
         message='Domain names must be labels separated by dots. Labels may consist of up to 63 letters, digits, '
-                'hyphens, and underscores. The last label may only contain letters.',
+                'hyphens, and underscores. The last label may not contain an underscore.',
         code='invalid_domain_name',
         flags=re.IGNORECASE
     )

+ 1 - 0
api/desecapi/tests/test_domains.py

@@ -257,6 +257,7 @@ class DomainOwnerTestCase1(DomainOwnerTestCase):
             '0.8.0.0.0.1.c.a.2.4.6.0.c.e.e.d.4.4.0.1.a.0.1.0.8.f.4.0.1.0.a.2.ip6.arpa',
             'very.long.domain.name.' + self.random_domain_name(),
             self.random_domain_name(),
+            'xn--90aeeb7afyklt.xn--p1ai',
         ]:
             with self.assertPdnsRequests(self.requests_desec_domain_creation(name)):
                 response = self.client.post(self.reverse('v1:domain-list'), {'name': name})

+ 4 - 0
docs/dns/domains.rst

@@ -85,6 +85,10 @@ Field details:
     characters as well as hyphens ``-`` and underscores ``_`` (except at the
     beginning of the name).  The maximum length is 191.
 
+    Internationalized domain names (IDN) currently are supported through their
+    Punycode representation only (labels beginning with ``xn--``).  Converters
+    are available on the net, for example at https://www.punycoder.com/.
+
 ``published``
     :Access mode: read-only