fix plugin path with whitespace (#5871)

This commit is contained in:
WindSoilder 2022-06-25 01:44:22 +08:00 committed by GitHub
parent 533e04a60a
commit f02076daa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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| {