grep: keep invalid UTF-8 text under -I (#49)

This commit is contained in:
Wondr
2026-06-05 15:06:49 +01:00
committed by GitHub
parent abcdd7e84d
commit 7c79cb4e3a
2 changed files with 16 additions and 1 deletions
+3 -1
View File
@@ -493,7 +493,9 @@ impl<'a> Searcher<'a> {
if let Some(positions) = self.session_match_line(line) {
// TODO: GNU grep respects LANG. Here, I'm always checking for valid UTF-8.
if !self.session_mark_binary_if(|| std::str::from_utf8(line).is_err()) {
if self.config.binary_mode != BinaryMode::WithoutMatch
&& !self.session_mark_binary_if(|| std::str::from_utf8(line).is_err())
{
return Ok(false);
}