Skip to content

fix: graceful error on non-UTF-8 --time-style value instead of panic#1840

Open
SAY-5 wants to merge 1 commit into
eza-community:mainfrom
SAY-5:fix-time-style-non-utf8-panic
Open

fix: graceful error on non-UTF-8 --time-style value instead of panic#1840
SAY-5 wants to merge 1 commit into
eza-community:mainfrom
SAY-5:fix-time-style-non-utf8-panic

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 20, 2026

Copy link
Copy Markdown
Description

eza --time-style VALUE aborted with a panic (exit 134) when VALUE was not valid UTF-8, e.g. eza --time-style "$(printf '\xff\xfe')" .. The custom TimeFormatParser::parse_ref called value.to_str().unwrap(), and OsStr::to_str() returns None for non-UTF-8, so the .unwrap() panicked.

This makes the parser return a clap InvalidUtf8 usage error when the value is not valid UTF-8, matching how every other flag rejects bad input. The sibling env-var path in view.rs already handles this with to_str().unwrap_or("").

Fixes #1837.

How Has This Been Tested?

cargo test --lib passes, including a new #[cfg(unix)] regression test that feeds a non-UTF-8 --time-style value and asserts a usage error rather than a panic. Manually confirmed eza --time-style "$(printf '\xff\xfe')" . now prints error: invalid UTF-8 in --time-style value instead of crashing. cargo fmt and cargo clippy --lib are clean.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: eza panics on a non-UTF-8 --time-style value (to_str().unwrap())

1 participant