From 47a7674c1419a0e655ac6097b77129406aeae7e2 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2026 19:52:30 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Fix=20unsafe=20unwrap=20on=20fil?= =?UTF-8?q?e=20path=20conversion=20in=20CLI=20and=20GUI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced `.to_str().unwrap()` with `.to_string_lossy()` when converting `PathBuf` to `String` to prevent potential crashes if the path contains invalid Unicode. This change improves the robustness of both the CLI and GUI components when handling file paths. - Modified `src/bin/cli.rs` to safely handle `file_path`. - Modified `src/gui/mod.rs` to safely handle `path` in `play_file`. Co-authored-by: arabianq <55220741+arabianq@users.noreply.github.com> --- src/bin/cli.rs | 2 +- src/gui/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/cli.rs b/src/bin/cli.rs index 45fdc53..5ea8cea 100644 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -144,7 +144,7 @@ async fn main() -> Result<(), Box> { Actions::Play { file_path, concurrent, - } => Request::play(file_path.to_str().unwrap(), concurrent), + } => Request::play(&file_path.to_string_lossy(), concurrent), Actions::ToggleLoop { id } => Request::toggle_loop(id), }, Commands::Get { parameter } => match parameter { diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 5f37d16..9b09cbf 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -113,7 +113,7 @@ impl SoundpadGui { } pub fn play_file(&mut self, path: &PathBuf, concurrent: bool) { - make_request_async(Request::play(path.to_str().unwrap(), concurrent)); + make_request_async(Request::play(&path.to_string_lossy(), concurrent)); } pub fn set_input(&mut self, name: String) {