mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-06 13:53:54 +02:00
feat(shell): enhance regex validators to match on entire string (#1603)
This commit is contained in:
committed by
GitHub
parent
b1e5cae5a0
commit
34df132fb1
@@ -88,9 +88,14 @@ impl ScopeObject for ScopeAllowedCommand {
|
||||
crate::scope_entry::ShellAllowedArg::Fixed(fixed) => {
|
||||
crate::scope::ScopeAllowedArg::Fixed(fixed)
|
||||
}
|
||||
crate::scope_entry::ShellAllowedArg::Var { validator } => {
|
||||
let validator = Regex::new(&validator)
|
||||
.unwrap_or_else(|e| panic!("invalid regex {validator}: {e}"));
|
||||
crate::scope_entry::ShellAllowedArg::Var { validator, raw } => {
|
||||
let regex = if raw {
|
||||
validator
|
||||
} else {
|
||||
format!("^{validator}$")
|
||||
};
|
||||
let validator = Regex::new(®ex)
|
||||
.unwrap_or_else(|e| panic!("invalid regex {regex}: {e}"));
|
||||
crate::scope::ScopeAllowedArg::Var { validator }
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user