From f02076daa8d17e14f5694cdd085969a9867796e4 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Sat, 25 Jun 2022 01:44:22 +0800 Subject: [PATCH] fix plugin path with whitespace (#5871) --- crates/nu-protocol/src/engine/engine_state.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index d02e895e0..0d45b86e9 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -362,9 +362,18 @@ impl EngineState { // No need to check the None option let (path, encoding, shell) = decl.is_plugin().expect("plugin should have file name"); - let file_name = path + let mut file_name = path .to_str() - .expect("path was checked during registration as a str"); + .expect("path was checked during registration as a str") + .to_string(); + + // Fix files or folders with quotes + if file_name.contains('\'') + || file_name.contains('"') + || file_name.contains(' ') + { + file_name = format!("`{}`", file_name); + } serde_json::to_string_pretty(&decl.signature()) .map(|signature| {