Skip to content

feat(parser): implement RFC 5322 email address parser with full ABNF coverage - #25

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

feat(parser): implement RFC 5322 email address parser with full ABNF coverage#25
GautamKumarOffical wants to merge 1 commit into
UnsafeLabs:mainfrom
GautamKumarOffical:feat/email-address-parser

Conversation

@GautamKumarOffical

Copy link
Copy Markdown

Implemented a complete RFC 5322 email address parser in Python, covering the full ABNF grammar from sections 3.2-3.4 plus obsolete syntax from section 4.4.

Changes

  • parser.py: class with , , methods
  • test_parser.py: 73 test cases organized by RFC section (exceeds the 60 required)
  • compliance.md: Maps all ABNF productions to tests and implementation
  • source.md: Added CAP annotation blocks at all marked locations

Features

  • Strict mode rejects all obs-* productions; permissive mode accepts them
  • Full quoted-string handling with quoted-pair and FWS per §3.2.4
  • CFWS correctly stripped, comments extracted and stored
  • Domain literals support IPv4 and IPv6 per §3.4.1
  • Group addresses with member list extraction
  • Pure Python stdlib only, no external dependencies
  • Type hints on all public methods

Test Coverage

Section Tests
§3.2.1 (quoted-pair) 5
§3.2.2 (FWS) 5
§3.2.3 (CFWS/comments) 8
§3.2.4 (quoted-string) 8
§3.2.5 (misc tokens) 3
§3.4 (address/mailbox/group) 12
§3.4.1 (addr-spec/domain-literal) 8
§4.4 (obsolete addressing) 8
Edge cases 5
Invalid/rejection 8
Total 73

Closes #1

…coverage

Added a Python parser implementing the complete ABNF grammar from
RFC 5322 sections 3.2-3.4, plus obsolete syntax from section 4.4.

- AddressParser class with parse(), parse_address_list(), parse_mailbox_list()
- RFC5322Address dataclass with display_name, local_part, domain, group support
- Strict/permissive mode for obs-* production handling
- 73 test cases covering quoted-pair, FWS, CFWS, quoted-string, addr-spec,
  domain literals (IPv4/IPv6), group addresses, and obsolete forms
- Compliance matrix mapping all ABNF productions to tests

Closes UnsafeLabs#1

Signed-off-by: Gautam Kumar <gautamkumarofficial@users.noreply.github.com>
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