feat(shell): enhance regex validators to match on entire string (#1603)

This commit is contained in:
Lucas Fernandes Nogueira
2024-08-02 10:03:35 -03:00
committed by GitHub
parent b1e5cae5a0
commit 34df132fb1
8 changed files with 45 additions and 9 deletions
+2 -1
View File
@@ -148,8 +148,9 @@ fn open_scope(open: &config::ShellAllowlistOpen) -> scope::OpenScope {
Some(Regex::new(r"^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+").unwrap())
}
config::ShellAllowlistOpen::Validate(validator) => {
let regex = format!("^{validator}$");
let validator =
Regex::new(validator).unwrap_or_else(|e| panic!("invalid regex {validator}: {e}"));
Regex::new(&regex).unwrap_or_else(|e| panic!("invalid regex {regex}: {e}"));
Some(validator)
}
};