mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #11135 from Zellic/ls-nonutf8-hidden
ls: Treat paths starting with a dot as hidden even if they contain invalid UTF-8.
This commit is contained in:
+1
-4
@@ -2399,10 +2399,7 @@ fn is_hidden(file_path: &DirEntry) -> bool {
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
file_path
|
||||
.file_name()
|
||||
.to_str()
|
||||
.is_some_and(|res| res.starts_with('.'))
|
||||
file_path.file_name().as_encoded_bytes().starts_with(b".")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7107,3 +7107,15 @@ fn test_ls_recursive_no_fd_leak() {
|
||||
.succeeds()
|
||||
.stderr_is("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
fn test_ls_non_utf8_hidden() {
|
||||
use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
at.touch(OsStr::from_bytes(b".hidden\x80"));
|
||||
|
||||
scene.ucmd().succeeds().stdout_does_not_contain(".hidden");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user