From ff9acf03cd48023b07b96d500f18b2d046647a23 Mon Sep 17 00:00:00 2001 From: Sai Asish Y Date: Fri, 19 Jun 2026 18:45:45 -0700 Subject: [PATCH 1/2] fix: graceful error on non-UTF-8 --time-style value instead of panic Signed-off-by: Sai Asish Y --- src/options/parser.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/options/parser.rs b/src/options/parser.rs index 5e8ba7da7..c55617e3c 100644 --- a/src/options/parser.rs +++ b/src/options/parser.rs @@ -316,7 +316,14 @@ impl clap::builder::TypedValueParser for TimeFormatParser { _arg: Option<&clap::Arg>, value: &std::ffi::OsStr, ) -> Result { - match TimeFormat::try_from_str(value.to_str().unwrap()) { + let Some(value) = value.to_str() else { + return Err(Error::raw( + clap::error::ErrorKind::InvalidUtf8, + "invalid UTF-8 in --time-style value\n", + ) + .with_cmd(cmd)); + }; + match TimeFormat::try_from_str(value) { Err(s) => Err(Error::raw(clap::error::ErrorKind::InvalidValue, s).with_cmd(cmd)), Ok(v) => Ok(v), } @@ -368,4 +375,14 @@ pub mod test { ["file1", "file2"] ); } + + #[cfg(unix)] + #[test] + fn time_style_non_utf8_is_a_usage_error() { + use std::os::unix::ffi::OsStringExt; + // A non-UTF-8 --time-style value should be a usage error, not a panic. + let value = OsString::from_vec(vec![0xff, 0xfe]); + let result = mock_cli_try(vec![OsString::from("--time-style"), value]); + assert!(result.is_err()); + } } From be4bbbeaa1a28a192139b0a391000a976b2a31c2 Mon Sep 17 00:00:00 2001 From: Sai Asish Y Date: Fri, 2 Oct 2026 02:57:28 -0700 Subject: [PATCH 2/2] test(cli): refresh version snapshots for 0.23.5 Match the package version used by the existing --version and -v cases. Assisted-by: Codex --- tests/ptests/ptest_a82ad7ec2e961f84.stdout | 2 +- tests/ptests/ptest_af29d370729835d8.stdout | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ptests/ptest_a82ad7ec2e961f84.stdout b/tests/ptests/ptest_a82ad7ec2e961f84.stdout index ca3b7e3a0..a0354c866 100644 --- a/tests/ptests/ptest_a82ad7ec2e961f84.stdout +++ b/tests/ptests/ptest_a82ad7ec2e961f84.stdout @@ -1,4 +1,4 @@ eza eza - A modern, maintained replacement for ls -v0.23.4 [+git] (pre-release debug build!) +v0.23.5 [+git] (pre-release debug build!) https://github.com/eza-community/eza diff --git a/tests/ptests/ptest_af29d370729835d8.stdout b/tests/ptests/ptest_af29d370729835d8.stdout index ca3b7e3a0..a0354c866 100644 --- a/tests/ptests/ptest_af29d370729835d8.stdout +++ b/tests/ptests/ptest_af29d370729835d8.stdout @@ -1,4 +1,4 @@ eza eza - A modern, maintained replacement for ls -v0.23.4 [+git] (pre-release debug build!) +v0.23.5 [+git] (pre-release debug build!) https://github.com/eza-community/eza