rfc822: remove unconditional parser diagnostics, unused bookkeeping, and stale commented implementations #12

Closed
opened 2026-07-21 17:20:21 +02:00 by heiko · 1 comment
Owner

Problem

The RFC 822 package retains debugging and dead bookkeeping that obscure the already complex parser/canonicalizer:

  • internal/rfc822/parser.go logs XXX: <offset> whenever p.offset > 0, even when debug tracing is disabled.
  • internal/rfc822/message.go maintains pos but never reads it.
  • internal/rfc822/normalize.go contains large blocks of commented-out implementation alongside the active regular-expression implementation.
  • Several comments describe behavior that no longer matches implementation closely enough to be executable documentation.

For an email filter, unexpected stderr output may leak fragments/state into MTA logs and makes diagnostics noisy.

Checklist: #2 (remove unnecessary code/nesting and keep the happy path clear).

Proposed fix

  • Remove the unconditional offset log and unused pos variable.
  • Delete dead commented code while keeping concise RFC citations and a short description of each canonicalization step.
  • Keep optional parser tracing behind an explicitly injected/test-only logger rather than package-global state.
  • Reconcile comments such as AddHeaders wrapping claims with actual behavior.

Acceptance criteria

  • Normal parsing emits no logs.
  • No unused bookkeeping or commented-out implementation remains.
  • Existing canonicalization fixtures remain byte-identical.
  • Parser/canonicalization tests and fuzz tests pass.

Reviewed against 948b7a9 on master (Go 1.26.2).

## Problem The RFC 822 package retains debugging and dead bookkeeping that obscure the already complex parser/canonicalizer: - `internal/rfc822/parser.go` logs `XXX: <offset>` whenever `p.offset > 0`, even when debug tracing is disabled. - `internal/rfc822/message.go` maintains `pos` but never reads it. - `internal/rfc822/normalize.go` contains large blocks of commented-out implementation alongside the active regular-expression implementation. - Several comments describe behavior that no longer matches implementation closely enough to be executable documentation. For an email filter, unexpected stderr output may leak fragments/state into MTA logs and makes diagnostics noisy. Checklist: #2 (remove unnecessary code/nesting and keep the happy path clear). ## Proposed fix - Remove the unconditional offset log and unused `pos` variable. - Delete dead commented code while keeping concise RFC citations and a short description of each canonicalization step. - Keep optional parser tracing behind an explicitly injected/test-only logger rather than package-global state. - Reconcile comments such as `AddHeaders` wrapping claims with actual behavior. ## Acceptance criteria - Normal parsing emits no logs. - No unused bookkeeping or commented-out implementation remains. - Existing canonicalization fixtures remain byte-identical. - Parser/canonicalization tests and fuzz tests pass. Reviewed against `948b7a9` on `master` (Go 1.26.2).
Author
Owner

Parser diagnostics/dead code cleanup and corrected AddHeaders documentation are complete.

Closing commit: 98a18c7e2be0

Parser diagnostics/dead code cleanup and corrected AddHeaders documentation are complete. Closing commit: [`98a18c7e2be0`](https://forgejo.schlittermann.de/heiko/mail-seal/commit/98a18c7e2be0214ea38d93569a7d2b623100732c)
heiko closed this issue 2026-07-21 23:07:56 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
heiko/mailseal#12
No description provided.