ssg

Function is_safe_path

Source
pub fn is_safe_path(path: &Path) -> Result<bool>
Expand description

Checks if a given path is safe to use.

Validates that the provided path does not contain directory traversal attempts or other potential security risks.

§Arguments

  • path - The path to validate

§Returns

  • Ok(true) - If the path is safe to use
  • Ok(false) - If the path contains unsafe elements
  • Err - If path validation fails

§Security

This function prevents directory traversal attacks by:

  • Resolving symbolic links
  • Checking for parent directory references (..)
  • Validating path components