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,尤其是 ScriptCharProvider::eat_spaces;issue 指出了空白字符处理的位置。先检查现有的 sed 解析器测试,并按照 issue 中的示例,添加对命令后的回车符和单行文本中的垂直制表符的测试覆盖。完成标准是这些输入的行为与 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 小时
- 30 天内合并 PR
- 40
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 于 22 天前认领。 未关闭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
-
bug good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
getsotto/sotto-authenticator#139 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
registrystack/registry-stack#2924 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
foundry-rs/starknet-foundry#4733 ·
维护者通常 4 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100