26
26
# addresses to also include three specific ranges of UTF8 defined in
27
27
# RFC3629 section 4, which appear to be the Unicode code points from
28
28
# U+0080 to U+10FFFF.
29
- ATEXT_UTF8 = ATEXT + u"\u0080 -\U0010FFFF "
30
- DOT_ATOM_TEXT_UTF8 = '[' + ATEXT_UTF8 + ']+(?:\\ .[' + ATEXT_UTF8 + ']+)*'
29
+ ATEXT_INTL = ATEXT + u"\u0080 -\U0010FFFF "
30
+ DOT_ATOM_TEXT_INTL = '[' + ATEXT_INTL + ']+(?:\\ .[' + ATEXT_INTL + ']+)*'
31
31
32
32
# The domain part of the email address, after IDNA (ASCII) encoding,
33
33
# must also satisfy the requirements of RFC 952/RFC 1123 which restrict
@@ -400,11 +400,11 @@ def validate_email_local_part(local, allow_smtputf8=True, allow_empty_local=Fals
400
400
401
401
else :
402
402
# The local part failed the ASCII check. Now try the extended internationalized requirements.
403
- m = re .match (DOT_ATOM_TEXT_UTF8 + "\\ Z" , local )
403
+ m = re .match (DOT_ATOM_TEXT_INTL + "\\ Z" , local )
404
404
if not m :
405
405
# It's not a valid internationalized address either. Report which characters were not valid.
406
406
bad_chars = ', ' .join (sorted (set (
407
- unicodedata .name (c , repr (c )) for c in local if not re .match (u"[" + (ATEXT if not allow_smtputf8 else ATEXT_UTF8 ) + u"]" , c )
407
+ unicodedata .name (c , repr (c )) for c in local if not re .match (u"[" + (ATEXT if not allow_smtputf8 else ATEXT_INTL ) + u"]" , c )
408
408
)))
409
409
raise EmailSyntaxError ("The email address contains invalid characters before the @-sign: %s." % bad_chars )
410
410
@@ -420,7 +420,7 @@ def validate_email_local_part(local, allow_smtputf8=True, allow_empty_local=Fals
420
420
421
421
# Check for unsafe characters.
422
422
# Some of this may be redundant with the range U+0080 to U+10FFFF that is checked
423
- # by DOT_ATOM_TEXT_UTF8 .
423
+ # by DOT_ATOM_TEXT_INTL .
424
424
for i , c in enumerate (local ):
425
425
category = unicodedata .category (c )
426
426
if category [0 ] in ("L" , "N" , "P" , "S" ):
0 commit comments