Skip to content

Fix validate.Email to accept IDNs#2937

Merged
sloria merged 2 commits intodevfrom
idn-emails
Apr 2, 2026
Merged

Fix validate.Email to accept IDNs#2937
sloria merged 2 commits intodevfrom
idn-emails

Conversation

@sloria
Copy link
Copy Markdown
Member

@sloria sloria commented Apr 2, 2026

closes #2936
same approach as #2928

if domain_part not in self.DOMAIN_WHITELIST:
if not self.DOMAIN_REGEX.match(domain_part):
try:
domain_part = domain_part.encode("idna").decode("ascii")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fallback is no longer necessary and previously resulted in a bug with accepting invalid IDN emails with leading or trailing hyphens

@sloria sloria enabled auto-merge (squash) April 2, 2026 12:53
@sloria sloria merged commit f07eadc into dev Apr 2, 2026
8 checks passed
@sloria sloria deleted the idn-emails branch April 2, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Email validator to support IDNs

1 participant