|
39 | 39 | # IANA Special Use Domain Names
|
40 | 40 | # Last Updated 2021-09-21
|
41 | 41 | # https://www.iana.org/assignments/special-use-domain-names/special-use-domain-names.txt
|
| 42 | +# |
42 | 43 | # The domain names without dots would be caught by the check that the domain
|
43 | 44 | # name in an email address must have a period, but this list will also catch
|
44 | 45 | # subdomains of these domains, which are also reserved.
|
45 | 46 | SPECIAL_USE_DOMAIN_NAMES = (
|
46 |
| - "arpa", # consolidated from a lot of arpa subdomains, we'll assume all subdomains of arpa are actually reserved |
47 |
| - "example", |
48 |
| - "example.com", |
49 |
| - "example.net", |
50 |
| - "example.org", |
| 47 | + # The "arpa" entry here is consolidated from a lot of arpa subdomains |
| 48 | + # for private address (i.e. non-routable IP addresses like 172.16.x.x) |
| 49 | + # reverse mapping, plus some other subdomains. Although RFC 6761 says |
| 50 | + # that application software should not treat these domains as special, |
| 51 | + # they are private-use domains and so cannot have globally deliverable |
| 52 | + # email addresses, which is an assumption of this library, and probably |
| 53 | + # all of arpa is similarly special-use, so we reject it all. |
| 54 | + "arpa", |
| 55 | + |
| 56 | + # RFC 6761 says applications "SHOULD NOT" treat the "example" domains |
| 57 | + # as special, i.e. applications should accept these domains. |
| 58 | + # |
| 59 | + # The domain "example" alone fails our syntax validation because it |
| 60 | + # lacks a dot (we assume no one has an email address on a TLD directly). |
| 61 | + # "@example.com/net/org" will currently fail DNS-based deliverability |
| 62 | + # checks because IANA publishes a NULL MX for these domains, and |
| 63 | + # "@mail.example[.com/net/org]" and other subdomains will fail DNS- |
| 64 | + # based deliverability checks because IANA does not publish MX or A |
| 65 | + # DNS records for these subdomains. |
| 66 | + # "example", # i.e. "wwww.example" |
| 67 | + # "example.com", |
| 68 | + # "example.net", |
| 69 | + # "example.org", |
| 70 | + |
| 71 | + # RFC 6761 says that applications are permitted to treat this domain |
| 72 | + # as special and that DNS should return an immediate negative response, |
| 73 | + # so we also immediately reject this domain, which also follows the |
| 74 | + # purpose of the domain. |
51 | 75 | "invalid",
|
| 76 | + |
| 77 | + # RFC 6762 says that applications "may" treat ".local" as special and |
| 78 | + # that "name resolution APIs and libraries SHOULD recognize these names |
| 79 | + # as special," and since ".local" has no global definition, we reject |
| 80 | + # it, as we expect email addresses to be gloally routable. |
52 | 81 | "local",
|
| 82 | + |
| 83 | + # RFC 6761 says that applications (like this library) are permitted |
| 84 | + # to treat "localhost" as special, and since it cannot have a globally |
| 85 | + # deliverable email address, we reject it. |
53 | 86 | "localhost",
|
| 87 | + |
| 88 | + # RFC 7686 says "applications that do not implement the Tor protocol |
| 89 | + # SHOULD generate an error upon the use of .onion and SHOULD NOT |
| 90 | + # perform a DNS lookup. |
54 | 91 | "onion",
|
55 |
| - "test", # see special logic for 'test' where this is checked |
| 92 | + |
| 93 | + # Although RFC 6761 says that application software should not treat |
| 94 | + # these domains as special, it also warns users that the address may |
| 95 | + # resolve differently in different systems, and therefore it cannot |
| 96 | + # have a globally routable email address, which is an assumption of |
| 97 | + # this library, so we reject "@test" and "@*.test" addresses, unless |
| 98 | + # the test_environment keyword argument is given, to allow their use |
| 99 | + # in application-level test environments. These domains will generally |
| 100 | + # fail deliverability checks because "test" is not an actual TLD. |
| 101 | + "test", |
56 | 102 | )
|
57 | 103 |
|
58 | 104 | # ease compatibility in type checking
|
@@ -501,11 +547,7 @@ def validate_email_domain_part(domain, test_environment=False):
|
501 | 547 | # Some might fail DNS-based deliverability checks, but that
|
502 | 548 | # can be turned off, so we should fail them all sooner.
|
503 | 549 | for d in SPECIAL_USE_DOMAIN_NAMES:
|
504 |
| - # RFC 6761 says that applications should not block use of the 'test' |
505 |
| - # domain name, presumably because that would prevent it from being |
506 |
| - # used for actual testing. We'll block it, except when a special |
507 |
| - # testing flag is used, indicating that the module is being used |
508 |
| - # in a test environment. |
| 550 | + # See the note near the definition of SPECIAL_USE_DOMAIN_NAMES. |
509 | 551 | if d == "test" and test_environment:
|
510 | 552 | continue
|
511 | 553 |
|
|
0 commit comments