Skip to content

Commit

Permalink
Escape glob patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master committed Dec 13, 2024
1 parent ca7f025 commit 1538e61
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
14 changes: 9 additions & 5 deletions crates/tauri-build/src/acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ permissions = [{default_permissions}]
}

tauri_utils::acl::build::define_permissions(
&plugin_out_dir.join("*").to_string_lossy(),
&PathBuf::from(glob::Pattern::escape(&plugin_out_dir.to_string_lossy()))
.join("*")
.to_string_lossy(),
name,
&plugin_out_dir,
|_| true,
Expand All @@ -222,10 +224,12 @@ permissions = [{default_permissions}]
);
}
permission_files.extend(tauri_utils::acl::build::define_permissions(
&default_permissions_path
.join("**")
.join("*")
.to_string_lossy(),
&PathBuf::from(glob::Pattern::escape(
&default_permissions_path.to_string_lossy(),
))
.join("**")
.join("*")
.to_string_lossy(),
name,
&plugin_out_dir,
|_| true,
Expand Down
17 changes: 10 additions & 7 deletions crates/tauri-bundler/src/bundle/windows/msi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,12 +929,11 @@ fn get_merge_modules(settings: &Settings) -> crate::Result<Vec<MergeModule>> {
let mut merge_modules = Vec::new();
let regex = Regex::new(r"[^\w\d\.]")?;
for msm in glob::glob(
settings
.project_out_directory()
.join("*.msm")
.to_string_lossy()
.to_string()
.as_str(),
&PathBuf::from(glob::Pattern::escape(
&settings.project_out_directory().to_string_lossy(),
))
.join("*.msm")
.to_string_lossy(),
)? {
let path = msm?;
let filename = path
Expand Down Expand Up @@ -1042,7 +1041,11 @@ fn generate_resource_data(settings: &Settings) -> crate::Result<ResourceMap> {
let mut dlls = Vec::new();

let out_dir = settings.project_out_directory();
for dll in glob::glob(out_dir.join("*.dll").to_string_lossy().to_string().as_str())? {
for dll in glob::glob(
&PathBuf::from(glob::Pattern::escape(&out_dir.to_string_lossy()))
.join("*.dll")
.to_string_lossy(),
)? {
let path = dll?;
let resource_path = dunce::simplified(&path);
let relative_path = path
Expand Down
1 change: 1 addition & 0 deletions crates/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ libc = "0.2"
swift-rs = "1.0.7"

[build-dependencies]
glob = "0.3"
heck = "0.5"
tauri-build = { path = "../tauri-build/", default-features = false, version = "2.0.3" }
tauri-utils = { path = "../tauri-utils/", version = "2.1.0", features = [
Expand Down
16 changes: 11 additions & 5 deletions crates/tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,12 @@ permissions = [{default_permissions}]
.unwrap_or_else(|_| panic!("unable to autogenerate default permissions"));

let permissions = tauri_utils::acl::build::define_permissions(
&permissions_out_dir
.join("**")
.join("*.toml")
.to_string_lossy(),
&PathBuf::from(glob::Pattern::escape(
&permissions_out_dir.to_string_lossy(),
))
.join("**")
.join("*.toml")
.to_string_lossy(),
&format!("tauri:{plugin}"),
out_dir,
|_| true,
Expand Down Expand Up @@ -432,7 +434,11 @@ permissions = [{}]
.unwrap_or_else(|_| panic!("unable to autogenerate core:default set"));

let _ = tauri_utils::acl::build::define_permissions(
&permissions_out_dir.join("*.toml").to_string_lossy(),
&PathBuf::from(glob::Pattern::escape(
&permissions_out_dir.to_string_lossy(),
))
.join("*.toml")
.to_string_lossy(),
"tauri:core",
out_dir,
|_| true,
Expand Down

0 comments on commit 1538e61

Please sign in to comment.