Skip to main content

resolve_within

Function resolve_within 

Source
pub fn resolve_within(root: &Path, path: &str) -> Result<PathBuf>
Expand description

Resolve a possibly-relative path against the workspace root.

Normalises both the root and candidate to absolute, dot-free form first, then performs a second check via canonicalize() (which follows symlinks) when the path already exists on disk. This prevents symlink-based escapes where a link inside the workspace points to a location outside it.

For paths that do not yet exist (e.g. a new file being written), only the lexical normalisation check is performed — the caller is responsible for ensuring no symlink is created that would bridge outside the root.