mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-18 16:57:19 +02:00
Merge commit from fork
* fix(shell): properly validate open scope * change empty regex to an impossible match --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app> Co-authored-by: Chip Reed <chip@chip.sh>
This commit is contained in:
@@ -75,7 +75,7 @@ impl<R: Runtime> Shell<R> {
|
||||
#[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")]
|
||||
#[allow(deprecated)]
|
||||
pub fn open(&self, path: impl Into<String>, with: Option<open::Program>) -> Result<()> {
|
||||
open::open(&self.open_scope, path.into(), with)
|
||||
open::open(None, path.into(), with)
|
||||
}
|
||||
|
||||
/// Open a (url) path with a default or specific browser opening program.
|
||||
@@ -147,7 +147,8 @@ pub fn init<R: Runtime>() -> TauriPlugin<R, Option<config::Config>> {
|
||||
fn open_scope(open: &config::ShellAllowlistOpen) -> scope::OpenScope {
|
||||
let shell_scope_open = match open {
|
||||
config::ShellAllowlistOpen::Flag(false) => None,
|
||||
config::ShellAllowlistOpen::Flag(true) => {
|
||||
// we want to add a basic regex validation even if the config is not set
|
||||
config::ShellAllowlistOpen::Unset | config::ShellAllowlistOpen::Flag(true) => {
|
||||
Some(Regex::new(r"^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+").unwrap())
|
||||
}
|
||||
config::ShellAllowlistOpen::Validate(validator) => {
|
||||
|
||||
Reference in New Issue
Block a user