mirror of
https://github.com/sharkdp/fd
synced 2024-10-06 07:49:18 +00:00
Skip invalid utf8 filenames, closes #250
This commit is contained in:
parent
631931b431
commit
47d95284aa
|
@ -217,6 +217,8 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
|
|||
if !exts_regex.is_match(path_str) {
|
||||
return ignore::WalkState::Continue;
|
||||
}
|
||||
} else {
|
||||
return ignore::WalkState::Continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -887,3 +887,26 @@ fn test_fixed_strings() {
|
|||
// Combine with --case-sensitive
|
||||
te.assert_output(&["--fixed-strings", "--case-sensitive", "download (1)"], "");
|
||||
}
|
||||
|
||||
/// Filenames with invalid UTF-8 sequences
|
||||
#[test]
|
||||
fn test_invalid_utf8() {
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
|
||||
let dirs = &["test1"];
|
||||
let files = &[];
|
||||
let te = TestEnv::new(dirs, files);
|
||||
|
||||
fs::File::create(
|
||||
te.test_root()
|
||||
.join(OsStr::from_bytes(b"test1/test_\xFEinvalid.txt")),
|
||||
).unwrap();
|
||||
|
||||
te.assert_output(&["", "test1/"], "test1/test_<74>invalid.txt");
|
||||
|
||||
te.assert_output(&["invalid", "test1/"], "test1/test_<74>invalid.txt");
|
||||
|
||||
// Should not be found under a different extension
|
||||
te.assert_output(&["-e", "zip", "", "test1/"], "");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue