Skip to main content

canonicalize_allow_missing

Function canonicalize_allow_missing 

Source
pub async fn canonicalize_allow_missing(normalized: &Path) -> Result<PathBuf>
Expand description

Canonicalize a path, walking up to find the nearest existing ancestor for new files.

This function handles paths to files that may not yet exist by finding the nearest existing parent directory, canonicalizing that, and then appending the remaining path components.

§Safety

This function is critical for security. It prevents symlink escapes by:

  1. Finding the nearest existing ancestor directory
  2. Canonicalizing that directory (resolves symlinks)
  3. Appending the remaining path components

§Arguments

  • normalized - A normalized path (output from normalize_path)

§Returns

The canonical path, or the normalized path if no parent exists