find: -printf: advance_one still panics on a multibyte char (after %, \, or a time directive)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start in src/find/matchers/printf.rs at advance_one and inspect how printf parsing consumes characters after %, \, and %A/%C/%T. Reproduce the issue with the find commands shown, then verify that multibyte characters no longer panic and that the output and exit status match the expected GNU behavior.
Written by the indexing model from the issue text.
Description
#723 fixed the -printf octal-escape peek path for multibyte characters, but advance_one still byte-slices and panics when a multibyte character follows a % conversion, a \ escape, or a %A/%C/%T time-field intro.
Steps to reproduce
$ mkdir d; touch d/a
$ find d -printf '%€\n'
thread 'main' panicked at src/find/matchers/printf.rs:152:35:
byte index 1 is not a char boundary; it is inside '€' (bytes 0..3) of `€`
$ echo $?
101
Same panic via find d -printf '\€\n' and find d -printf '%A€' (and %C, %T).
Expected (GNU)
$ /usr/bin/find d -printf '%€\n'
find: warning: unrecognized format directive '%€'
%€
$ echo $?
0
Cause
After reading a full char, advance_one drops it by slicing one byte:
// src/find/matchers/printf.rs:150
fn advance_one(&mut self) -> Result<char, Box<dyn Error>> {
let c = self.front()?;
self.string = &self.string[1..]; // line 152: byte 1 is mid-char for a multibyte `c`
Ok(c)
}
When c is multibyte, byte index 1 isn't a char boundary, so the slice panics.
- Dominant language
- Rust
- Stars
- 649
- Forks
- 101
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 11
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from uutils/findutils
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
good first issue
Difficulty 3/5 1-2 days Newbie friendliness 62/100
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
-
good first issue
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
good first issue
Difficulty 3/5 1-2 days Newbie friendliness 52/100
All issues in uutils/findutils
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100