Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/email_validator/rfc_constants.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:32 +0000

1# These constants are defined by the email specifications. 

2 

3import re 

4 

5# Based on RFC 5322 3.2.3, these characters are permitted in email 

6# addresses (not taking into account internationalization) separated by dots: 

7ATEXT = r'a-zA-Z0-9_!#\$%&\'\*\+\-/=\?\^`\{\|\}~' 

8ATEXT_RE = re.compile('[.' + ATEXT + ']') # ATEXT plus dots 

9DOT_ATOM_TEXT = re.compile('[' + ATEXT + ']+(?:\\.[' + ATEXT + r']+)*\Z') 

10 

11# RFC 6531 3.3 extends the allowed characters in internationalized 

12# addresses to also include three specific ranges of UTF8 defined in 

13# RFC 3629 section 4, which appear to be the Unicode code points from 

14# U+0080 to U+10FFFF. 

15ATEXT_INTL = ATEXT + u"\u0080-\U0010FFFF" 

16ATEXT_INTL_RE = re.compile('[.' + ATEXT_INTL + ']') # ATEXT_INTL plus dots 

17DOT_ATOM_TEXT_INTL = re.compile('[' + ATEXT_INTL + ']+(?:\\.[' + ATEXT_INTL + r']+)*\Z') 

18 

19# The domain part of the email address, after IDNA (ASCII) encoding, 

20# must also satisfy the requirements of RFC 952/RFC 1123 2.1 which 

21# restrict the allowed characters of hostnames further. 

22ATEXT_HOSTNAME_INTL = re.compile(r"[a-zA-Z0-9\-\." + "\u0080-\U0010FFFF" + "]") 

23HOSTNAME_LABEL = r'(?:(?:[a-zA-Z0-9][a-zA-Z0-9\-]*)?[a-zA-Z0-9])' 

24DOT_ATOM_TEXT_HOSTNAME = re.compile(HOSTNAME_LABEL + r'(?:\.' + HOSTNAME_LABEL + r')*\Z') 

25DOMAIN_NAME_REGEX = re.compile(r"[A-Za-z]\Z") # all TLDs currently end with a letter 

26 

27# Domain literal (RFC 5322 3.4.1) 

28DOMAIN_LITERAL_CHARS = re.compile(r"[\u0021-\u00FA\u005E-\u007E]") 

29 

30# Quoted-string local part (RFC 5321 4.1.2, internationalized by RFC 6531 3.3) 

31# The permitted characters in a quoted string are the characters in the range 

32# 32-126, except that quotes and (literal) backslashes can only appear when escaped 

33# by a backslash. When internationalized, UTF8 strings are also permitted except 

34# the ASCII characters that are not previously permitted (see above). 

35# QUOTED_LOCAL_PART_ADDR = re.compile(r"^\"((?:[\u0020-\u0021\u0023-\u005B\u005D-\u007E]|\\[\u0020-\u007E])*)\"@(.*)") 

36QUOTED_LOCAL_PART_ADDR = re.compile(r"^\"((?:[^\"\\]|\\.)*)\"@(.*)") 

37QTEXT_INTL = re.compile(r"[\u0020-\u007E\u0080-\U0010FFFF]") 

38 

39# Length constants 

40# RFC 3696 + errata 1003 + errata 1690 (https://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690) 

41# explains the maximum length of an email address is 254 octets. 

42EMAIL_MAX_LENGTH = 254 

43LOCAL_PART_MAX_LENGTH = 64 

44DNS_LABEL_LENGTH_LIMIT = 63 # in "octets", RFC 1035 2.3.1 

45DOMAIN_MAX_LENGTH = 255 # in "octets", RFC 1035 2.3.4 and RFC 5321 4.5.3.1.2 

46 

47# RFC 2142 

48CASE_INSENSITIVE_MAILBOX_NAMES = [ 

49 'info', 'marking', 'sales', 'support', # section 3 

50 'abuse', 'noc', 'security', # section 4 

51 'postmaster', 'hostmaster', 'usenet', 'news', 'webmaster', 'www', 'uucp', 'ftp', # section 5 

52]