Skip to content

Commit 4d0e2ec

Browse files
authored
fix(core): scope should not strip the first path component, closes #3592 (#3602)
1 parent 929a83d commit 4d0e2ec

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Fixes filesystem and asset scope stripping the first component of the allowed path.

core/tauri/src/api/path.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,22 @@ pub fn parse<P: AsRef<Path>>(
138138
) -> crate::api::Result<PathBuf> {
139139
let mut p = PathBuf::new();
140140
let mut components = path.as_ref().components();
141-
if let Some(Component::Normal(str)) = components.next() {
142-
if let Some(base_directory) = BaseDirectory::from_variable(&str.to_string_lossy()) {
143-
p.push(resolve_path(
144-
config,
145-
package_info,
146-
env,
147-
"",
148-
Some(base_directory),
149-
)?);
150-
} else {
151-
p.push(str);
141+
match components.next() {
142+
Some(Component::Normal(str)) => {
143+
if let Some(base_directory) = BaseDirectory::from_variable(&str.to_string_lossy()) {
144+
p.push(resolve_path(
145+
config,
146+
package_info,
147+
env,
148+
"",
149+
Some(base_directory),
150+
)?);
151+
} else {
152+
p.push(str);
153+
}
152154
}
155+
Some(component) => p.push(component),
156+
None => (),
153157
}
154158

155159
for component in components {

0 commit comments

Comments
 (0)