Expand description
Path sanitation and directory traversal defense.
Enums§
- Path
Sanitize Error - Errors arising during filename sanitization, validation, or path resolution.
Constants§
- MAX_
FILENAME_ BYTES - Maximum allowed length in bytes for a single filename component.
Functions§
- is_
reserved_ windows_ name - Checks if the given filename or stem matches a reserved Windows device name (case-insensitive).
- resolve_
destination_ path - Resolves and secures a destination path inside
base_dirfrom an untrusted filename. - resolve_
unique_ destination_ path - Resolves a non-colliding destination path inside
base_dir. - sanitize_
filename - Sanitizes an untrusted filename string to produce a safe single-component filename.
- sanitize_
relative_ path - Sanitizes an untrusted relative path string to produce a safe relative PathBuf.
- validate_
filename - Validates that a string is a safe, single-component filename without any sanitization or modification.