Skip to content

tar: quote member names consistently in listings - #384

Open
SichenLiang wants to merge 1 commit into
uutils:mainfrom
SichenLiang:quote-listing-names
Open

SichenLiang wants to merge 1 commit into
uutils:mainfrom
SichenLiang:quote-listing-names

Conversation

@SichenLiang

Copy link
Copy Markdown

Use one byte-oriented writer for member names in both plain and verbose listings. It preserves spaces, quotes backslashes and common control characters with C escapes, and uses three-digit octal escapes for other control or invalid bytes.

Locale selection follows LC_ALL, LC_CTYPE, then LANG, ignoring empty values. In C, POSIX, or when all three are unset or empty, every non-ASCII byte is quoted. Other locale names use UTF-8 rules. Windows keeps ordinary Unicode text and quotes controls, backslashes, U+2028, and U+2029.

This is local rather than using uucore::quoting_style because that helper escapes spaces, which tar listings must preserve. Enabling it would also add the ICU locale data dependency. The code can move to uucore later if the shared helper gains the behavior tar needs.

Non-UTF-8 locales and some Unicode printability cases remain outside this change. #277 will need porting; the current #376 changes merge textually, and the merged result builds and passes the Linux tests.

Fixes #383

Use one writer for plain and verbose listings. Quote invalid UTF-8
bytes, backslashes and control characters. In C, POSIX, or when all
locale variables are unset or empty, quote every non-ASCII byte:
café is printed as caf\303\251. Windows keeps ordinary non-ASCII
names as text regardless of locale variables.

Locale precedence skips empty LC_ALL, LC_CTYPE and LANG values. Other
locale names use UTF-8 quoting, so non-UTF-8 locales and some Unicode
printability cases remain outside this change.
@SichenLiang
SichenLiang requested a review from kaladron as a code owner October 2, 2026 04:16
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.05769% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.51%. Comparing base (791ae26) to head (ed1e1e2).
⚠️ Report is 72 commits behind head on main.

Files with missing lines Patch % Lines
tests/by-util/test_tar.rs 65.85% 28 Missing ⚠️
src/uu/tar/src/operations/list.rs 98.82% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #384      +/-   ##
==========================================
- Coverage   96.84%   96.51%   -0.34%     
==========================================
  Files          11       15       +4     
  Lines        1492     1951     +459     
  Branches       29       43      +14     
==========================================
+ Hits         1445     1883     +438     
- Misses         46       67      +21     
  Partials        1        1              
Flag Coverage Δ
macos_latest 97.91% <99.44%> (+1.07%) ⬆️
ubuntu_latest 97.91% <99.44%> (+1.07%) ⬆️
windows_latest 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@codspeed

codspeed Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing SichenLiang:quote-listing-names (ed1e1e2) with main (93e211f)

Open in CodSpeed

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.

tar: listing a member can lose its original name bytes

1 participant