pub fn resolve_doc_path(
docs_dir: &Path,
rel: &str,
) -> Result<PathBuf, PathGuardError>Expand description
Resolve a client-supplied doc-relative path (e.g. "guide/intro.md") to a
canonical absolute path strictly inside docs_dir, or reject. docs_dir
MUST already be canonicalized by the caller. Layered checks mirror the
original validateRepoDocPath:
- backslash ->
Traversal; absolute / leading/->Absolute. - strip leading
./; any..component ->Traversal; empty ->Traversal. - require a
.mdsuffix -> elseNotMarkdown. - lexical:
docs_dir.join(rel)must stay underdocs_dir. canonicalize(): missing ->NotFound; realpath escapingdocs_dir(symlink escape) ->Traversal.- the canonical target must be a regular file -> else
NotAFile.