#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.
#723 fixed the
-printfoctal-escapepeekpath for multibyte characters, butadvance_onestill byte-slices and panics when a multibyte character follows a%conversion, a\escape, or a%A/%C/%Ttime-field intro.Steps to reproduce
Expected (GNU)
Cause
After reading a full char,
advance_onedrops it by slicing one byte:When
cis multibyte, byte index 1 isn't a char boundary, so the slice panics.