Explorar el Código

fix(core): ignore trailing slashes on scope validation, closes #3580 (#3601)

Lucas Fernandes Nogueira hace 3 años
padre
commit
929a83dd4d
Se han modificado 2 ficheros con 11 adiciones y 1 borrados
  1. 5 0
      .changes/fix-path-scope-validation.md
  2. 6 1
      core/tauri/src/scope/fs.rs

+ 5 - 0
.changes/fix-path-scope-validation.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Ignore trailing slashes on path scope validation.

+ 6 - 1
core/tauri/src/scope/fs.rs

@@ -2,7 +2,10 @@
 // SPDX-License-Identifier: Apache-2.0
 // SPDX-License-Identifier: MIT
 
-use std::{fmt, path::Path};
+use std::{
+  fmt,
+  path::{Path, PathBuf},
+};
 
 use glob::Pattern;
 use tauri_utils::{
@@ -44,6 +47,7 @@ impl Scope {
     let mut allow_patterns = Vec::new();
     for path in &scope.0 {
       if let Ok(path) = parse_path(config, package_info, env, path) {
+        let path: PathBuf = path.components().collect();
         allow_patterns.push(Pattern::new(&path.to_string_lossy()).expect("invalid glob pattern"));
         #[cfg(windows)]
         {
@@ -66,6 +70,7 @@ impl Scope {
     };
 
     if let Ok(path) = path {
+      let path: PathBuf = path.components().collect();
       let allowed = self.allow_patterns.iter().any(|p| p.matches_path(&path));
       allowed
     } else {