Skip to main content

Module path

Module path 

Source
Expand description

Path sanitation and directory traversal defense.

Enums§

PathSanitizeError
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_dir from 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.