Skip to content

Commit

Permalink
fix(core): scope should not strip the first path component, closes #3592
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Mar 3, 2022
1 parent 929a83d commit 4d0e2ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-path-scope-first-component.md
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Fixes filesystem and asset scope stripping the first component of the allowed path.
26 changes: 15 additions & 11 deletions core/tauri/src/api/path.rs
Expand Up @@ -138,18 +138,22 @@ pub fn parse<P: AsRef<Path>>(
) -> crate::api::Result<PathBuf> {
let mut p = PathBuf::new();
let mut components = path.as_ref().components();
if let Some(Component::Normal(str)) = components.next() {
if let Some(base_directory) = BaseDirectory::from_variable(&str.to_string_lossy()) {
p.push(resolve_path(
config,
package_info,
env,
"",
Some(base_directory),
)?);
} else {
p.push(str);
match components.next() {
Some(Component::Normal(str)) => {
if let Some(base_directory) = BaseDirectory::from_variable(&str.to_string_lossy()) {
p.push(resolve_path(
config,
package_info,
env,
"",
Some(base_directory),
)?);
} else {
p.push(str);
}
}
Some(component) => p.push(component),
None => (),
}

for component in components {
Expand Down

0 comments on commit 4d0e2ec

Please sign in to comment.