Skip to main content

escapes_root

Function escapes_root 

Source
pub fn escapes_root(path: impl AsRef<Path>) -> bool
Expand description

Whether path, resolved against a workspace root, would land outside it.

Two ways a workspace-relative path can escape the tree it is joined onto: an absolute path (or a Windows drive prefix), which root.join(path) jumps to wholesale, ignoring the root entirely; and one whose normalized form still leads with .., a climb above the root that the parent/.. folding could not cancel. Either is refused by the read/write guards (prov’s Workspace’s load, prov’s ChangeSet::apply) so a relation target — which is data, authored by whoever wrote the document — can never name a file the workspace does not contain.

A path that stays within the root (notes/a.md, ../sibling/b.md where the document is nested deeply enough that the .. cancels) returns false.