diff --git a/crates/tauri/src/path/mod.rs b/crates/tauri/src/path/mod.rs index f9f79bed3..b6d2c6ea4 100644 --- a/crates/tauri/src/path/mod.rs +++ b/crates/tauri/src/path/mod.rs @@ -27,6 +27,17 @@ pub use android::PathResolver; pub use desktop::PathResolver; /// A wrapper for [`PathBuf`] that prevents path traversal. +/// +/// # Examples +/// +/// ``` +/// # use tauri::path::SafePathBuf; +/// assert!(SafePathBuf::new("../secret.txt".into()).is_err()); +/// assert!(SafePathBuf::new("/home/user/stuff/../secret.txt".into()).is_err()); +/// +/// assert!(SafePathBuf::new("./file.txt".into()).is_ok()); +/// assert!(SafePathBuf::new("/home/user/secret.txt".into()).is_ok()); +/// ``` #[derive(Clone, Debug, Serialize)] pub struct SafePathBuf(PathBuf);