Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Sanitization requires color, which parses every record

オープン
#419 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

  • #420 @kskalski による — マージされずにクローズ

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust
領域
observability

調査の方向性

src/writer/mod.rs:134 から始め、色が無効な場合の AutoStream のパスを sanitization と anstyle-parse の処理を通して追跡します。記載されたベンチマークを再現し、その後、C0 および DEL バイトが無効化され、newline と tab が変更されず、色のパスに影響がなく、正当な非 ASCII 入力が選択した動作に従って処理されることを検証します。

索引モデルが issue の本文から書いたものです。

説明

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)
主要言語
Rust
スター
1.1k
フォーク
150
平均マージ
3分
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rust-cli/env_logger のほかの issue

rust-cli/env_logger の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。