We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
SafePathBuf
1 parent b8c0d7e commit cf0b358Copy full SHA for cf0b358
crates/tauri/src/path/mod.rs
@@ -27,6 +27,17 @@ pub use android::PathResolver;
27
pub use desktop::PathResolver;
28
29
/// A wrapper for [`PathBuf`] that prevents path traversal.
30
+///
31
+/// # Examples
32
33
+/// ```
34
+/// # use tauri::path::SafePathBuf;
35
+/// assert!(SafePathBuf::new("../secret.txt".into()).is_err());
36
+/// assert!(SafePathBuf::new("/home/user/stuff/../secret.txt".into()).is_err());
37
38
+/// assert!(SafePathBuf::new("./file.txt".into()).is_ok());
39
+/// assert!(SafePathBuf::new("/home/user/secret.txt".into()).is_ok());
40
41
#[derive(Clone, Debug, Serialize)]
42
pub struct SafePathBuf(PathBuf);
43
0 commit comments