Skip to content

Accept tagged IPv6 email address literals - #526

Open
pabszero wants to merge 3 commits into
python-validators:masterfrom
pabszero:fix-email-tagged-ipv6-literals
Open

pabszero wants to merge 3 commits into
python-validators:masterfrom
pabszero:fix-email-tagged-ipv6-literals

Conversation

@pabszero

Copy link
Copy Markdown

With ipv6_address=True, email("user@[2001:db8::1]", ...) accepts a bare IPv6 literal, but user@[IPv6:2001:db8::1] is rejected. The tagged form is defined by RFC 5321 section 4.1.3.

Recognize the tag case-insensitively and validate its payload as IPv6. Preserve opt-in flag behavior, legacy address literals and local-part validation. Regressions cover compressed, full and IPv4-embedded addresses, invalid payloads (including zone IDs), repeated brackets and compatibility.

Validation on Windows:

  • New regression selection against the original implementation: 4 failed, 6 passed; all pass with the fix.
  • Full suite: 1,181 passed on both CPython 3.12 and 3.13.
  • Configured tox lint, type and SAST environments passed; check-only formatting passed.

Other operating systems and Python 3.11/3.14 were not run locally. AI assistance (OpenAI Codex) was used for investigation, implementation, review and testing.

@nandgator

Copy link
Copy Markdown
Collaborator

Thanks, I've reviewed this and would like to merge it. The tagged literal matches the IPv6-address-literal rule in RFC 5321, the tag is case-insensitive as ABNF strings are, and zone IDs, CIDR suffixes and IPv4 payloads are rejected.

It now conflicts with master in tests/test_email.py, because I added regression tests at the same spot. Both sides only add tests, so the resolution is to keep both. Could you rebase onto master and force-push? I'll approve CI and merge once it's green.

@pabszero

Copy link
Copy Markdown
Author

Resolved the conflict in ce9157c, keeping your IDNA lookalike tests and all IPv6 literal regressions. I used GitHub’s web conflict resolver, so this is a merge from master rather than a force-pushed rebase. The complete resulting tree matches the locally tested rebased tree.

On Windows CPython 3.12 and 3.13, the updated full suite passes: 1,584 tests per version, including all 45 email cases. Tox lint, type and SAST checks and the check-only formatter also pass. Hosted workflows are awaiting maintainer approval.

This branch has not been deployed

No deployments
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.

2 participants