Skip to content

Fix ascii_local_part/smtputf8 after NFC normalization of local part - #186

Open
faresrafat3 wants to merge 2 commits into
JoshData:mainfrom
faresrafat3:185-nfc-normalized-ascii-local-part
Open

faresrafat3 wants to merge 2 commits into
JoshData:mainfrom
faresrafat3:185-nfc-normalized-ascii-local-part

Conversation

@faresrafat3

@faresrafat3 faresrafat3 commented Nov 2, 2026 •

Copy link
Copy Markdown

Fixes #185.

When an NFC-normalized local part differs from the original (e.g. the Kelvin sign U+212A normalizes to ASCII K), validate_email revalidated the normalized part but kept the pre-normalization ascii_local_part and smtputf8 values. Update those fields from the second validation result so an ASCII normalized address reports ascii_local_part/ascii_email and smtputf8=False.

What I verified:

$ python -c "from email_validator import validate_email; r = validate_email('\u212a@example.com', check_deliverability=False); print(r.normalized, r.ascii_local_part, r.ascii_email, r.smtputf8)"
K@example.com K K@example.com False

320 tests pass; flake8 and mypy clean.

What I did not verify: deliverability (DNS) paths, since the fix is in the syntax/normalization layer and check_deliverability was disabled in all test runs. Quoted local parts with embedded non-ASCII that does not NFC-normalize to ASCII are not exercised beyond the existing test suite.

When an NFC-normalized local part differs from the original (e.g. the Kelvin
sign U+212A normalizes to ASCII K), validate_email revalidated the normalized
part but kept the pre-normalization ascii_local_part and smtputf8 values.
Update those fields from the second validation result so an ASCII normalized
address reports ascii_local_part/ascii_email and smtputf8=False.

Fixes JoshData#185.
Copilot AI balanced review requested due to automatic review settings November 2, 2026 10:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Unquote the NFC-normalized local part before re-validation so that
validate_email_local_part (which expects an unquoted value and re-quotes
it when quoted_local_part is True) does not double-escape. Also use the
re-validated local_part value instead of the raw NFC string.

Addresses review finding on PR JoshData#186.
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.

NFC-normalized ASCII local part still reports SMTPUTF8 required

2 participants