diff options
author | Canop <cano.petrole@gmail.com> | 2021-08-01 22:20:49 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-08-01 22:20:49 +0200 |
commit | ff90aed3c0a9c53204639459f742b558a085ec20 (patch) | |
tree | d7ddf06bedf999c578fa640e20def204725b089e | |
parent | 41846168ebfdf1eeb8f1fef82d692ba894ee4e22 (diff) |
check args are set on external execution
Previously it was possible to have {new_path} as
name of a new file because the argument wasn't filled.
Now the execution is prevented (as was the case in old
versions before a refactoring)
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/app/panel_state.rs | 9 | ||||
-rw-r--r-- | src/shell_install/bash.rs | 1 | ||||
-rw-r--r-- | src/verb/verb.rs | 1 |
4 files changed, 9 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4753291..46c7c23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### next - hjson: fix bad parsing on tab alignement +- now check all args of externals are set, doesn't use the raw {arg} <a name="v1.6.2"></a> ### v1.6.2 - 2021-07-31 diff --git a/src/app/panel_state.rs b/src/app/panel_state.rs index 63af80a..bae620f 100644 --- a/src/app/panel_state.rs +++ b/src/app/panel_state.rs @@ -461,9 +461,16 @@ pub trait PanelState { app_state: &mut AppState, cc: &CmdContext, ) -> Result<CmdResult, ProgramError> { + let sel_info = self.sel_info(app_state); + if let Some(invocation) = &invocation { + if let Some(error) = verb.check_args(&sel_info, &invocation, &app_state.other_panel_path) { + debug!("verb.check_args prevented execution: {:?}", &error); + return Ok(CmdResult::error(error)); + } + } let exec_builder = ExecutionStringBuilder::with_invocation( &verb.invocation_parser, - self.sel_info(app_state), + sel_info, app_state, if let Some(inv) = invocation { &inv.args diff --git a/src/shell_install/bash.rs b/src/shell_install/bash.rs index a313983..4343b58 100644 --- a/src/shell_install/bash.rs +++ b/src/shell_install/bash.rs @@ -17,7 +17,6 @@ use { }, directories::UserDirs, lazy_regex::regex, - minimad::*, regex::Captures, std::{env, fs::OpenOptions, io::Write, path::PathBuf}, termimad::mad_print_inline, diff --git a/src/verb/verb.rs b/src/verb/verb.rs index 99ec5bc..c800b06 100644 --- a/src/verb/verb.rs +++ b/src/verb/verb.rs @@ -245,7 +245,6 @@ impl Verb { return "You can't focus without selection".to_string(); } } - // TODO check that before } let builder = || { |