@@ -128,7 +128,7 @@ def validate_email_local_part(local, allow_smtputf8=True, allow_empty_local=Fals
128
128
raise EmailSyntaxError ("The email address is too long before the @-sign." )
129
129
130
130
# Check the local part against the regular expression for the older ASCII requirements.
131
- m = re .match (DOT_ATOM_TEXT + "$ " , local )
131
+ m = re .match (DOT_ATOM_TEXT + "\\ Z " , local )
132
132
if m :
133
133
# Return the local part unchanged and flag that SMTPUTF8 is not needed.
134
134
return {
@@ -138,7 +138,7 @@ def validate_email_local_part(local, allow_smtputf8=True, allow_empty_local=Fals
138
138
139
139
else :
140
140
# The local part failed the ASCII check. Now try the extended internationalized requirements.
141
- m = re .match (DOT_ATOM_TEXT_UTF8 + "$ " , local )
141
+ m = re .match (DOT_ATOM_TEXT_UTF8 + "\\ Z " , local )
142
142
if not m :
143
143
# It's not a valid internationalized address either. Report which characters were not valid.
144
144
bad_chars = ', ' .join (sorted (set (
@@ -226,15 +226,15 @@ def validate_email_domain_part(domain):
226
226
227
227
# Check the regular expression. This is probably entirely redundant
228
228
# with idna.decode, which also checks this format.
229
- m = re .match (DOT_ATOM_TEXT + "$ " , domain )
229
+ m = re .match (DOT_ATOM_TEXT + "\\ Z " , domain )
230
230
if not m :
231
231
raise EmailSyntaxError ("The email address contains invalid characters after the @-sign." )
232
232
233
233
# All publicly deliverable addresses have domain named with at least
234
234
# one period. We also know that all TLDs end with a letter.
235
235
if "." not in domain :
236
236
raise EmailSyntaxError ("The domain name %s is not valid. It should have a period." % domain_i18n )
237
- if not re .search (r"[A-Za-z]$ " , domain ):
237
+ if not re .search (r"[A-Za-z]\Z " , domain ):
238
238
raise EmailSyntaxError (
239
239
"The domain name %s is not valid. It is not within a valid top-level domain." % domain_i18n
240
240
)
0 commit comments