feat(transfer): add DisableASCIIConversion to skip CRLF/LF rewriting#636
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
Summary
Adds a new
Settings.DisableASCIIConversion bool(defaultfalse) that letsoperators opt out of the ASCII-mode CRLF/LF rewriting performed during TYPE A
transfers, as requested in #615.
When
true:STOR/RETRin TYPE A pass through byte-for-byte; no\ris stripped onupload and no
\ris inserted on download.SIZEis allowed in ASCII mode, because the on-disk size now matches whatwill 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 clientsthat do not want the server to modify their files.
Closes #615.
Test plan
go build ./...go test -race ./...— 185 tests passTestASCIITransfersWithConversionDisabledcovers:CRLF + lone LFbuffer in TYPE A preserves the on-disk size byte-for-byteSIZEreturns the file size in ASCII modeRETRround-trip hash matches the local fileTestASCIITransfers,TestASCIITransfersInvalidFiles,TestSIZEstill pass (unchanged default behavior)golangci-lint: no new findings vs. main