Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Sanitization requires color, which parses every record

Aperta
#419 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
observability

Direzione di ricerca

Inizia da src/writer/mod.rs:134 e segui il percorso di AutoStream con il colore disabilitato attraverso la sanitizzazione e la gestione di anstyle-parse. Riproduci il benchmark indicato, quindi verifica che i byte C0 e DEL vengano neutralizzati, che newline e tab rimangano invariati, che il percorso del colore non venga influenzato e che l’input non ASCII legittimo venga gestito secondo il comportamento scelto.

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

Descrizione

Problem

With styling disabled, AutoStream still walks every record through anstyle-parse's VT state machine, roughly doubling per-record cost even for builds emitting no styling.

Target::Stderr/dev/null, 161-byte records, 500k iterations, release + LTO, 8 interleaved rounds:

ns/record
with color 596
without color 302

Turning off just auto-color doesn't avoid it — WriteStyle::Auto then collapses to Never (src/writer/mod.rs:134), making the parse unconditional. Only dropping color entirely removes the parser.

However dropping color also removes sanitization, as the two share a code path, so untrusted input then reaches the reader's terminal verbatim:

Note: deactivating the build-time feature color is not a mitigation as that
removes all ANSI escape code stripping from env_logger.

Neither configuration avoids both. The coupling isn't required though: without color there is no styling emitted, so nothing needs parsing, only payload bytes need neutralizing.

Proposal

Escape C0 and DEL as \xNN when color is off, sparing \n and \t.

  • 319 ns/record measured, so sanitizing costs ~17 ns over the unsafe build today
  • color path untouched, no behavior change for anyone using it
  • differs from the strip it replaces in both directions:
    • stricter on \r, VT and FF, which anstream passes through
    • more permissive on raw C1 and stray continuation bytes, which anstream drops (matching it there needs full UTF-8 validation — ~20 lines, free for ASCII records, ~+40 ns/record for records with legitimate non-ASCII)
Lingua principale
Rust
Stelle
1.1k
Fork
149
Merge medio
2h 42m
PR unite (30g)
4

Guida per i contributori

Apri la guida per i contributori

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 rust-cli/env_logger

Tutte le issue di rust-cli/env_logger

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.