Repository navigation
Fix mailbox selection and expose forensic address recovery defects - #176
Merged
Merged
Conversation
The ReDoS hardening in 5aab122 excluded whitespace inside angle addresses, causing the fallback to select an email-like display name instead of the mailbox (issue #175). Parse structural boundaries with quote, escape, comment and group awareness. Preserve recovery and ambiguity evidence in address_header_defects while retaining first-occurrence address semantics. Validated with 775 tests on Python 3.13 and 3.14, the 432-header regression matrix, 20,000 malformed-input probes, scaling checks and pre-commit.
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.
Fix mailbox selection when malformed address headers contain a trusted-looking display name before an angle-address. For
From: billing@trusted.example < billing@vendor.example >, the parser now returnsbilling@vendor.exampleas the mailbox, preservesbilling@trusted.exampleas display-name evidence, and reportsinvalid-display-nameinstead of silently selecting the display text.Closes #175
Changes relative to master
address_header_defectswith the reason, raw item, recovery status, candidates, header name, and occurrence. Include diagnostics in full/partial mail and JSON output, sethas_defectsandAddressHeaderDefect, and protect the computed metadata from colliding wire headers.AGENTS.md, imported byCLAUDE.md, and require RFC 5322 checks and evidence-preserving recovery for future code changes.uv.lock; project dependency declarations and the stdlib-only core remain unchanged.Expected behavior
RFC 5322 sections 3.2.3, 3.2.5, and 3.4 distinguish display names from mailboxes; section 4 covers obsolete syntax accepted by receivers. Whitespace around the mailbox inside angle brackets is permitted; the unquoted
@in this example's display name is the defect.structural-recoverycan also indicate a limitation of the standard-library parser and is not, by itself, proof of noncompliance. This recovery policy is not a complete RFC validator or a guarantee of how all mail clients interpret malformed messages.Validation