Skip to content
Myr

Skip invalid utf8 filenames, closes #250

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by David Peter · parent 631931b · Browse files · 2 files+25 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+25 added−0 removed

  • tests:+23 added−0 removed
  • other:+2 added−0 removed

2 files+25 added−0 removed

modified:src/walk.rs+2 added
215 unmodified lines
216 if let Some(path_str) = entry_path.file_name().map_or(None, |s| s.to_str()) {217 if !exts_regex.is_match(path_str) {218 return ignore::WalkState::Continue;219 }220 } else {221 return ignore::WalkState::Continue;222 }223 }224225 let search_str_o = if config.search_full_path {
30 unmodified lines
modified:tests/tests.rs+23 added
885 unmodified lines
886887 // Combine with --case-sensitive888 te.assert_output(&["--fixed-strings", "--case-sensitive", "download (1)"], "");889}890891/// Filenames with invalid UTF-8 sequences892#[test]893fn test_invalid_utf8() {894 use std::ffi::OsStr;895 use std::os::unix::ffi::OsStrExt;896897 let dirs = &["test1"];898 let files = &[];899 let te = TestEnv::new(dirs, files);900901 fs::File::create(902 te.test_root()903 .join(OsStr::from_bytes(b"test1/test_\xFEinvalid.txt")),904 ).unwrap();905906 te.assert_output(&["", "test1/"], "test1/test_�invalid.txt");907908 te.assert_output(&["invalid", "test1/"], "test1/test_�invalid.txt");909910 // Should not be found under a different extension911 te.assert_output(&["-e", "zip", "", "test1/"], "");912}