Skip to main content

safe_path

Function safe_path 

Source
pub fn safe_path(
    path: &Path,
    allowed_root: &Path,
) -> Result<PathBuf, SecurityError>
Expand description

Ensure a path stays within an allowed directory (no ../ traversal).

Uses canonicalize to resolve symlinks and relative components. Returns PathNotFound for non-existent paths (distinguishable from PathTraversal) and PathTraversal for actual escape attempts.