Skip to content

feat(transfer): add DisableASCIIConversion to skip CRLF/LF rewriting#636

Merged
fclairamb merged 2 commits into
mainfrom
feat/disable-ascii-conversion
May 16, 2026
Merged

feat(transfer): add DisableASCIIConversion to skip CRLF/LF rewriting#636
fclairamb merged 2 commits into
mainfrom
feat/disable-ascii-conversion

Conversation

@fclairamb

Copy link
Copy Markdown
Owner

Summary

Adds a new Settings.DisableASCIIConversion bool (default false) that lets
operators opt out of the ASCII-mode CRLF/LF rewriting performed during TYPE A
transfers, as requested in #615.

When true:

  • STOR / RETR in TYPE A pass through byte-for-byte; no \r is stripped on
    upload and no \r is inserted on download.
  • SIZE is allowed in ASCII mode, because the on-disk size now matches what
    will be transferred.

When false (default), behavior is unchanged and remains RFC 959 compliant.

This matches the toggle other servers expose (e.g. vsftpd
ascii_download_enable=NO / ascii_upload_enable=NO) and is useful for clients
that do not want the server to modify their files.

Closes #615.

Test plan

  • go build ./...
  • go test -race ./... — 185 tests pass
  • New TestASCIITransfersWithConversionDisabled covers:
    • STOR of a CRLF + lone LF buffer in TYPE A preserves the on-disk size byte-for-byte
    • SIZE returns the file size in ASCII mode
    • RETR round-trip hash matches the local file
  • Existing TestASCIITransfers, TestASCIITransfersInvalidFiles, TestSIZE still pass (unchanged default behavior)
  • golangci-lint: no new findings vs. main

When Settings.DisableASCIIConversion is true, TYPE A (ASCII) transfers
are passed through byte-for-byte instead of going through the
CRLF<->LF converter, and SIZE is allowed in ASCII mode since the
on-disk size now matches the transfer size. Default false preserves
the current RFC 959 behavior.

This matches vsftpd's ascii_download_enable/ascii_upload_enable=NO
and is useful for clients that do not want the server to modify their
files.

Closes #615
@codecov

codecov Bot commented May 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.22%. Comparing base (1620b5c) to head (5e08d97).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #636   +/-   ##
=======================================
  Coverage   87.22%   87.22%           
=======================================
  Files          13       13           
  Lines        2090     2090           
=======================================
  Hits         1823     1823           
  Misses        180      180           
  Partials       87       87           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fclairamb fclairamb changed the title feat(settings): add DisableASCIIConversion to skip CRLF/LF rewriting feat(transfer): add DisableASCIIConversion to skip CRLF/LF rewriting May 16, 2026
@fclairamb fclairamb enabled auto-merge (squash) May 16, 2026 17:07
@fclairamb fclairamb merged commit 5d53235 into main May 16, 2026
6 checks passed
@fclairamb fclairamb deleted the feat/disable-ascii-conversion branch May 16, 2026 17:09
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.

Option to disable ASCII EOL conversion

1 participant