Skip to content

fix: preserve mail evidence and correct RFC parsing - #180

Merged
fedelemantuano merged 3 commits into
developfrom
improve/rfc-standards
Oct 1, 2026
Merged

fedelemantuano merged 3 commits into
developfrom
improve/rfc-standards

Conversation

@fedelemantuano

Copy link
Copy Markdown
Contributor

Description

This PR fixes parsing behavior that could discard original bytes, silently normalize impossible dates, or interpret delimiters in the wrong context. Recovery preserves the original evidence and reports defects even when it succeeds.

  • Read files as bytes, preserving undecodable octets and original MIME line endings.
  • Validate dates and add diagnostics for Date, Resent-Date, and Received timestamps while retaining valid obsolete syntax.
  • Include named, explicitly inline text parts in body output while preserving their attachment representation.
  • Decode encoded words in their proper lexical context, keeping quoted values literal.
  • Parse Received fields structurally and prevent forged HELO content from influencing sender-IP attribution.
  • Preserve Unicode MIME metadata and safely handle incorrect charsets and codecs that produce non-serializable values.

Adds targeted tests, regression checks against the existing corpus, and updates documentation and the shared security-review procedure.

Validation: 1,238 tests and 5 subtests passed on Python 3.13 and 3.14. All 69 corpus cases were checked across Python 3.9–3.14 without new exceptions. Pre-commit, lint, and Pyright passed. A dedicated security review completed with no remaining High/Medium findings.

Compatibility: file input now honors the declared charset, consistently with the bytes API. Messages with incorrect charset declarations may display differently; their original bytes remain available.

Reviewed against RFC 5322 §§3.3–3.4, 3.6.7, 4–5 and applicable SMTP/MIME standards.

Preserve file octets and MIME metadata, validate date semantics, include
named inline text in body views, decode display words in lexical context,
and scan Received fields structurally with safe sender-IP attribution.
Keep recovery diagnostics and raw evidence, including unsafe codec output.

Add targeted regressions and audited corpus fingerprints. Document the
intentional file-input charset compatibility change and shared review rules.

RFC review: RFC 5322 sections 3.3, 3.4, 3.6.7, 4 and 5; RFC 5321 section
4.4; applicable RFC 2045/2046, 2047, 2183, 2231 and 6532 requirements.

Validation: 1238 tests and 5 subtests passed on Python 3.13 and 3.14;
69 corpus cases checked across Python 3.9-3.14 without new exceptions.
Pre-commit, lint and Pyright passed. Dedicated security review completed;
all reproduced High/Medium findings fixed and retested.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 99.321% (-0.4%) from 99.765% — improve/rfc-standards into develop

@fedelemantuano
fedelemantuano merged commit fa419af into develop Oct 1, 2026
8 checks passed
@fedelemantuano
fedelemantuano deleted the improve/rfc-standards branch October 1, 2026 22:13
@fedelemantuano
fedelemantuano restored the improve/rfc-standards branch October 1, 2026 22:16
@fedelemantuano
fedelemantuano deleted the improve/rfc-standards branch October 2, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants