numfmt: non-UTF-8 filename in an unselected field prevents size conversion

Aperta
#16,771 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cli

Direzione di ricerca

The default whitespace path in src/uu/numfmt/src/numfmt.rs (around lines 58-72) validates the whole line as UTF-8 before selecting fields, so start there. Reproduce with the printf command from the issue under LC_ALL=C and compare against GNU numfmt. Done when field 1 converts to 1.5k and 2.5k, the non-UTF-8 filename passes through byte for byte, and the existing numfmt tests still pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

With a size in field 1 and a filename in field 2, a non-UTF-8 byte in the filename stops the entire listing.

printf '1500 caf\351.txt\n2500 notes.txt\n' | LC_ALL=C numfmt --field=1 --to=si

uutils exits 2 with empty stdout and numfmt: invalid number: '1500 caf\351.txt'. GNU exits 0, converts the sizes to 1.5k and 2.5k, and preserves the filenames byte for byte. With --invalid=ignore, uutils exits 0 but leaves the first size as 1500. Adding --delimiter=' ' gives the expected output on this input.

Verified on x86_64 Linux with uutils 0.12.0, 0.13.0, and a local build of main at 791399596cc7214e76c0c6bd022332ab6048ec65. Compared against GNU coreutils 9.7 and 9.12.

The default whitespace path validates the entire line as UTF-8 before selecting fields. https://github.com/uutils/coreutils/blob/791399596cc7214e76c0c6bd022332ab6048ec65/src/uu/numfmt/src/numfmt.rs#L58-L72

Lingua principale
Rust
Stelle
24.4k
Fork
2.2k
Merge medio
2g 23h
PR unite (30g)
402

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di uutils/coreutils

Tutte le issue di uutils/coreutils

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.