diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs index e06e671de1..d78f6d6a32 100644 --- a/codex-rs/tui/src/bottom_pane/chat_composer.rs +++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs @@ -191,7 +191,7 @@ impl ChatComposer { let placeholder = format!("[Pasted Content {char_count} chars]"); self.textarea.insert_element(&placeholder); self.pending_pastes.push((placeholder, pasted)); - } else if self.handle_paste_image_paths(pasted.clone()) { + } else if self.handle_paste_image_path(pasted.clone()) { self.textarea.insert_str(" "); } else { self.textarea.insert_str(&pasted); @@ -201,7 +201,7 @@ impl ChatComposer { true } - pub fn handle_paste_image_paths(&mut self, pasted: String) -> bool { + pub fn handle_paste_image_path(&mut self, pasted: String) -> bool { let Some(path_buf) = normalize_pasted_path(&pasted) else { return false; }; diff --git a/codex-rs/tui/src/bottom_pane/string_utils.rs b/codex-rs/tui/src/bottom_pane/string_utils.rs index 86b56c2d78..63fb1541a4 100644 --- a/codex-rs/tui/src/bottom_pane/string_utils.rs +++ b/codex-rs/tui/src/bottom_pane/string_utils.rs @@ -14,8 +14,7 @@ pub fn normalize_pasted_path(pasted: &str) -> Option { return parts.into_iter().next().map(PathBuf::from); } - // simple quoted path fallback - Some(PathBuf::from(pasted.trim_matches('"'))) + None } pub fn get_img_format_label(path: PathBuf) -> String { @@ -71,6 +70,14 @@ mod tests { assert_eq!(result, PathBuf::from(r"C:\Users\Alice\My File.jpeg")); } + #[test] + fn normalize_multiple_tokens_returns_none() { + // Two tokens after shell splitting → not a single path + let input = "/home/user/a\\ b.png /home/user/c.png"; + let result = normalize_pasted_path(input); + assert!(result.is_none()); + } + #[test] fn img_format_label_png_jpeg_unknown() { assert_eq!(get_img_format_label(PathBuf::from("/a/b/c.PNG")), "PNG");