Skip to content

nntp: test article payload whitespace preservation - #367

Draft
OllieinCanada wants to merge 2 commits into
sashiko-dev:mainfrom
OllieinCanada:fix/320-nntp-whitespace
Draft

nntp: test article payload whitespace preservation#367
OllieinCanada wants to merge 2 commits into
sashiko-dev:mainfrom
OllieinCanada:fix/320-nntp-whitespace

Conversation

@OllieinCanada

@OllieinCanada OllieinCanada commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up regression coverage for #320.

Summary

Add a deterministic localhost mock-server test for the NNTP article payload
whitespace fix merged in c3b5584.

While this pull request was still a draft, upstream merged the production fix
and closed #320. The branch has therefore been updated to current main, and
the duplicate implementation was removed. The cumulative diff now contains
only regression coverage for the accepted behavior.

Coverage

The test exercises the real NntpClient::article() path and verifies:

  • normal payload lines
  • trailing spaces and tabs
  • a one-space unified-diff context line
  • ordinary empty lines
  • added, removed, and context lines ending in whitespace
  • LF-only framing
  • NNTP dot-unstuffing
  • article terminator exclusion
  • line ordering and count
  • production-style newline reconstruction

The mock server binds only to an ephemeral localhost port, verifies the
ARTICLE command, and is awaited so server-task failures cannot be hidden.

Validation

  • focused release-mode NNTP regression test passes
  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features --release -- -D warnings
  • complete release suite passes with 406 tests passed and 15 ignored when
    excluding the known old-Git portability test tracked by tests: make bad-tag recovery test portable across Git versions #350
  • git diff --check
  • DCO sign-off check passes

make check-pr RANGE=upstream/main..HEAD completed formatting and clippy
successfully; its unfiltered local test phase encountered only the known #350
failure with Git 2.25.1.

No external NNTP server, kernel checkout, LLM, paid API, database, or Docker
container is required.

Signed-off-by: OllieinCanada <73385593+OllieinCanada@users.noreply.github.com>
Signed-off-by: OllieinCanada <73385593+OllieinCanada@users.noreply.github.com>
@OllieinCanada OllieinCanada changed the title nntp: preserve trailing whitespace in article payloads nntp: test article payload whitespace preservation Jul 24, 2026
davidehu-69 added a commit to davidehu-69/sashiko that referenced this pull request Jul 29, 2026
Preserve trailing spaces and tabs when reading NNTP lines by replacing
generic trim_end() with trim_end_matches(['\r', '\n']). Stripping trailing
whitespace corrupts patch diff hunks and causes git apply to fail.

Fix RFC 3977 dot-unstuffing to strip leading periods on non-terminator
lines starting with '.', and return an explicit error on premature EOF.

Sanitize newlines in email display names to prevent lettre builder panics.

Tested manually by replaying patch diffs containing exact tabs, trailing
spaces, and dot-prefixed filenames (.gitignore) against git apply.

Closes: sashiko-dev#367

Signed-off-by: Davide Hu <davidehu@google.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.

patch corruption issue: Trailing tab / blank line by error removed, causing "Failed To Apply" problem.

1 participant