sed - script parser skips CR, VT, FF (and 0x85, 0xA0) as blanks; GNU skips only space and tab
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
src/sed/script_char_provider.rsを読み、特にissueで空白文字の処理箇所として示されているScriptCharProvider::eat_spacesを確認してください。まず既存のsedパーサーテストを確認し、issueの例に従って、コマンドの後のキャリッジリターンと1行テキスト内の垂直タブをテストに追加してください。これらの入力がGNU sedと同じ動作をし、テストが通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
Wherever the script parser skips blanks (between address and command, after a command, before
one-line a/i/c text, before a w/r file name, ...), GNU sed skips only space and tab.
uutils sed skips every Unicode whitespace character, including carriage return, vertical tab,
form feed and the raw bytes 0x85 and 0xA0. As a result:
- a script saved with CRLF line endings runs here, where GNU stops with
extra characters after command; - a leading
\v,\for\ris silently dropped from one-linea/i/ctext and from
file names.
Reproduction
Rust (incorrect)
$ printf 'a\n' | ./target/release/sed $'p\r'
a
a
# Exit code: 0
$ printf 'a\n' | ./target/release/sed $'1a\vfoo' | od -An -c
a \n f o o \n
# Exit code: 0
GNU (correct)
$ printf 'a\n' | /usr/bin/sed $'p\r'
/usr/bin/sed: -e expression #1, char 2: extra characters after command
# Exit code: 1
$ printf 'a\n' | /usr/bin/sed $'1a\vfoo' | od -An -c
a \n \v f o o \n
# Exit code: 0
Root cause
ScriptCharProvider::eat_spaces in src/sed/script_char_provider.rs:64-69:
/// Advances the position past any whitespace characters.
pub fn eat_spaces(&mut self) {
while self.pos < self.line.len() && self.current().is_whitespace() {
self.advance();
}
}
current() maps each byte to a char, so char::is_whitespace is also true for the bytes
0x85 and 0xA0 (U+0085, U+00A0).
Test
#[test]
fn test_carriage_return_after_command_rejected() {
new_ucmd!()
.arg("p\r")
.pipe_in("a\n")
.fails()
.code_is(1);
}
#[test]
fn test_vertical_tab_kept_in_one_line_text() {
new_ucmd!()
.arg("1a\x0bfoo")
.pipe_in("a\n")
.succeeds()
.stdout_is("a\n\x0bfoo\n");
}
Reported by Anthropic's OSS Scanner (ANT-2026-Q3PRSLF7).
- 主要言語
- Rust
- スター
- 123
- フォーク
- 53
- 平均マージ
- 2日 8時間
- マージ済み PR(30日)
- 40
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
uutils/sed のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
sed - with `--posix`, `-e 'i\'` takes the next `-e` as its text対応中かも @yunusarda-sudo が 14 日前に担当しました。 オープンbug gnu-compat good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
sed - with `-s` or `-i`, the file read by `R` is not restarted for each input file対応中かも @Himanshu-singh04 が 22 日前に担当しました。 オープンbug gnu-compat good first issue oss-scanner
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
sed - output already produced is lost when a runtime error stops processing対応中かも @Himanshu-singh04 が 21 日前に担当しました。 オープンbug gnu-compat good first issue oss-scanner
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
sed - unknown POSIX class names like `[[:foo:]]` or `[[:word:]]` are accepted instead of rejected対応中かも @draarivpatel-ui が 7 日前に担当しました。 オープンbug gnu-compat good first issue oss-scanner
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
autofix:working
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
libracoder/kiri#1138 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
roc-lang/basic-webserver#277 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
samkerrcode/opengent#113 ·
メンテナーはふだん 1 日以内に返信
-
app bug session
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信