Skip to main content

path_to_safe_dirname

Function path_to_safe_dirname 

Source
pub fn path_to_safe_dirname(path: &str) -> String
Expand description

Convert a remote path to a safe directory name.

Sanitizes path by:

  • Removing leading ~ and /
  • Replacing path separators and spaces with underscores
  • Removing parent directory references (..) to prevent traversal attacks
  • Removing current directory references (.)
  • Appending a stable hash to prevent collisions (e.g., “foo/bar” vs “foo_bar”)