Skip to main content

sanitize_existing_path

Function sanitize_existing_path 

Source
pub fn sanitize_existing_path(path: &str) -> Result<PathBuf>
Expand description

Sanitize and validate a user-provided path.

This function:

  1. Expands tilde (~) to home directory
  2. Checks for path traversal sequences
  3. Canonicalizes the path (requires it to exist)
  4. Validates the path is under an allowed base directory

Returns the sanitized, canonicalized path.