Skip to content

feat(protocol): apply FilenameConverter on sender flist emit (#1912) - #3548

Merged
oferchen merged 1 commit into
masterfrom
feat/iconv-sender-emit-1912
May 2, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/iconv-sender-emit-1912

Conversation

@oferchen

@oferchen oferchen commented May 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Wires the existing apply_encoding_conversion hook on the sender's file-list emit path so filenames are transcoded from local to remote charset before prefix-compression bookkeeping and wire emission when --iconv=remote,local is in effect.
  • Annotates the iconv call site in FileListWriter::write_entry with the upstream reference flist.c send_file_entry() iconv_buf(ic_send, ...) so the protocol-fidelity contract is visible at the wire boundary.
  • Mirrors FileListWriter::with_iconv on BatchedFileListWriter so the batched sender path can attach a converter through the same builder surface.

Why

The audit at docs/audits/iconv-pipeline.md (Finding 4) flagged that the conversion helper existed but no production caller emitted converted bytes. PR #1911 (feat(core): wire IconvSetting to FilenameConverter at config build) plumbed the resolved converter into transfer::ConnectionConfig::iconv and engine::LocalCopyOptions::iconv, and transfer::generator::build_flist_writer already calls writer.with_iconv(...) from connection.iconv. With this change, the hook now takes effect end-to-end whenever the runtime config carries a resolved converter, so --iconv stops being a silent no-op for sender flist emit.

The follow-ups for receiver ingest (#1913) and filter-rule path matching (#1914) remain tracked separately.

Tests

  • crates/protocol/src/flist/write/tests.rs::write_entry_transcodes_filename_with_iconv_to_remote_charset (feature-gated iconv): asserts that a UTF-8 source name "café.txt" emerges on the wire as the ISO-8859-1 byte sequence [0x63, 0x61, 0x66, 0xe9, 0x2e, 0x74, 0x78, 0x74] and that the UTF-8 form of é (0xc3 0xa9) does not appear.
  • crates/protocol/src/flist/write/tests.rs::write_entry_without_iconv_emits_raw_filename_bytes: asserts the no-converter path still emits raw filename bytes unchanged, preserving current behaviour.

Test plan

  • CI: fmt + clippy
  • CI: nextest (stable)
  • CI: Windows (stable)
  • CI: macOS (stable)
  • CI: Linux musl (stable)

Upstream

  • target/interop/upstream-src/rsync-3.4.1/flist.c lines 1579-1603, send_file_entry() filename iconvbufs(ic_send, ...) (dirname + '/' + basename).

Tracker: #1912.

@oferchen
oferchen marked this pull request as ready for review May 1, 2026 22:13
@github-actions github-actions Bot added the enhancement New feature or request label May 1, 2026
Wires the existing `apply_encoding_conversion` hook on the sender's
file-list emit path so filenames are transcoded from local to remote
charset before any prefix-compression bookkeeping or wire emission
when --iconv=remote,local is in effect. The producer wiring tracker
in `crates/engine/src/local_copy/options/filters.rs` (#1911) named
this gap explicitly, and the SSH/daemon producer in
`transfer::generator::build_flist_writer` already calls
`writer.with_iconv(...)` from `connection.iconv`, so the hook now
takes effect end-to-end whenever the runtime config carries a
resolved converter.

Changes:

- Annotate the iconv conversion call site in
  `FileListWriter::write_entry` with the upstream reference
  `flist.c send_file_entry() iconv_buf(ic_send, ...)` so the
  protocol-fidelity contract is visible at the wire boundary.
- Mirror `FileListWriter::with_iconv` on `BatchedFileListWriter`
  so the batched sender path can attach a converter through the
  same builder surface.
- Add unit tests in `crates/protocol/src/flist/write/tests.rs`
  covering the with-converter round-trip (UTF-8 source name -> wire
  bytes are ISO-8859-1, no UTF-8 multi-byte sequence remains) and
  the without-converter path (wire bytes match the original
  filename, preserving current behaviour).

upstream: flist.c send_file_entry() iconv_buf(ic_send, ...)
audit: docs/audits/iconv-pipeline.md, Finding 4
@oferchen
oferchen force-pushed the feat/iconv-sender-emit-1912 branch from 8116e49 to 8ad5cbf Compare May 2, 2026 01:28
@oferchen
oferchen merged commit c8478eb into master May 2, 2026
37 checks passed
@oferchen
oferchen deleted the feat/iconv-sender-emit-1912 branch May 2, 2026 03:50
oferchen added a commit that referenced this pull request May 5, 2026
…3548)

Wires the existing `apply_encoding_conversion` hook on the sender's
file-list emit path so filenames are transcoded from local to remote
charset before any prefix-compression bookkeeping or wire emission
when --iconv=remote,local is in effect. The producer wiring tracker
in `crates/engine/src/local_copy/options/filters.rs` (#1911) named
this gap explicitly, and the SSH/daemon producer in
`transfer::generator::build_flist_writer` already calls
`writer.with_iconv(...)` from `connection.iconv`, so the hook now
takes effect end-to-end whenever the runtime config carries a
resolved converter.

Changes:

- Annotate the iconv conversion call site in
  `FileListWriter::write_entry` with the upstream reference
  `flist.c send_file_entry() iconv_buf(ic_send, ...)` so the
  protocol-fidelity contract is visible at the wire boundary.
- Mirror `FileListWriter::with_iconv` on `BatchedFileListWriter`
  so the batched sender path can attach a converter through the
  same builder surface.
- Add unit tests in `crates/protocol/src/flist/write/tests.rs`
  covering the with-converter round-trip (UTF-8 source name -> wire
  bytes are ISO-8859-1, no UTF-8 multi-byte sequence remains) and
  the without-converter path (wire bytes match the original
  filename, preserving current behaviour).

upstream: flist.c send_file_entry() iconv_buf(ic_send, ...)
audit: docs/audits/iconv-pipeline.md, Finding 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant