Repository navigation
Fix ascii_local_part/smtputf8 after NFC normalization of local part - #186
Open
faresrafat3 wants to merge 2 commits into
Open
faresrafat3 wants to merge 2 commits into
faresrafat3 wants to merge 2 commits into
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #185.
When an NFC-normalized local part differs from the original (e.g. the Kelvin sign U+212A normalizes to ASCII K),
validate_emailrevalidated the normalized part but kept the pre-normalizationascii_local_partandsmtputf8values. Update those fields from the second validation result so an ASCII normalized address reportsascii_local_part/ascii_emailandsmtputf8=False.What I verified:
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.