Skip to content

feat: implement RFC 5322 compliant email address parser#2

Open
MichisGitIsKing wants to merge 1 commit into
UnsafeLabs:mainfrom
MichisGitIsKing:feat/email-parser
Open

feat: implement RFC 5322 compliant email address parser#2
MichisGitIsKing wants to merge 1 commit into
UnsafeLabs:mainfrom
MichisGitIsKing:feat/email-parser

Conversation

@MichisGitIsKing
Copy link
Copy Markdown

RFC 5322 Email Address Parser

Full implementation of the ABNF grammar from sections 3.2-3.4 + obsolete syntax from 4.4.

Deliverables

  • parser.py (638 lines): AddressParser with strict/permissive modes, RFC5322Address dataclass
  • test_parser.py (413 lines): 75 individual test cases organized by RFC section
  • compliance.md: Maps all 27 ABNF productions to parser methods and test cases

Coverage

  • 75 tests, all passing, 0 failures
  • Every ABNF production mapped and tested
  • Strict mode rejects obs-* productions; permissive accepts them

Highlights

  • Pure Python stdlib, zero dependencies
  • Full quoted-string, quoted-pair, CFWS/comment handling
  • IPv4 + IPv6 domain literals
  • Group addresses with member extraction
  • obs-local-part, obs-domain, obs-angle-addr, obs-route
  • Type hints on all public methods
  • Handles inputs up to 998 characters

Fixes #1

- Full ABNF grammar (§3.2-§3.4 + §4.4 obsolete syntax)
- AddressParser with strict/permissive modes
- RFC5322Address dataclass with all required fields
- Handles: quoted-strings, quoted-pairs, CFWS/comments,
  domain literals (IPv4+IPv6), group addresses, obs-local-part
- Pure Python stdlib, no external dependencies
- Type hints on all public methods
- 75 test cases covering all RFC sections (requirement: 60+)
- Comprehensive compliance matrix mapping all 27 ABNF productions

Fixes UnsafeLabs#1
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.

[bounty $400] Implement ABNF-compliant email address parser with full §3.2–§4.4 coverage

1 participant