Skip to content

fix: print valid locale characters raw on the client like 3.5.2 - #8397

Merged
oferchen merged 1 commit into
masterfrom
fix/client-output-locale-escaping
Nov 17, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/client-output-locale-escaping

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Under a UTF-8 locale a client printed every non-ASCII file name escaped (caf\#303\#251) where rsync 3.5.2 prints café.

  • A client without -8 now checks terminal output against the locale codeset, as upstream does with ic_chck (rsync.c:95-98, log.c:462-499): valid printable characters print raw; invalid bytes, C0 controls other than tab, DEL and C1 controls are escaped; a literal \#ddd keeps its guard.
  • The codeset comes from setlocale(LC_CTYPE, "") and nl_langinfo(CODESET) (main.c:1911), through a new platform::locale, set before any thread starts. It replaces a guess from the text of LANG/LC_*.
  • Server and daemon output, -8 and log files are unchanged.
  • EscapeStyle docs and citations now describe 3.5.2's filtered_fwrite; the redundant escape_c1 field is removed with no behaviour change.

Tests

  • crates/cli/tests/client_output_locale_escaping.rs: seven cells compare stdout byte for byte with the rsync 3.5.2 binary (--list-only, -rv, -ri under C.UTF-8 and C, plus -rv8). Before the fix the three UTF-8 cells fail; the C and -8 cells pass either way and act as controls. The test fails, not skips, in CI when the oracle is missing.
  • Eleven unit tests in logging/src/escape.rs; two fail when the codeset check is forced off.

Known gaps

  • Codesets other than ASCII and UTF-8 (ISO-8859-x, GBK, EUC-JP) keep the conservative escaping, since they cannot be validated without iconv; upstream prints a printable Latin-1 byte raw. A unit test pins this.
  • Windows keeps the conservative escaping.
  • The server path is covered by a unit test, not an end-to-end cell.

A client without -8 now checks its terminal output against the locale
codeset, as rsync 3.5.2 does with ic_chck (rsync.c:95-98,
log.c:462-499). Printable UTF-8 names print raw; invalid bytes, C0,
DEL and C1 are still escaped as \#ooo. The codeset comes from
setlocale(LC_CTYPE, "") and nl_langinfo(CODESET) (main.c:1911)
instead of sniffing the LANG and LC_* text. Servers, -8 and the log
file keep their escaping.

The EscapeStyle docs now describe the 3.5.2 filtered_fwrite, which
dropped the escape_c1 argument; the matching field is removed because
every escaping path already covers 0x80-0x9F.
@oferchen
oferchen force-pushed the fix/client-output-locale-escaping branch from 79f2cf0 to cb596b2 Compare November 17, 2026 12:15
@github-actions github-actions Bot added the bug Something isn't working label Nov 17, 2026
@oferchen
oferchen merged commit 773253e into master Nov 17, 2026
157 of 158 checks passed
@oferchen
oferchen deleted the fix/client-output-locale-escaping branch November 17, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant