Skip to main content

Module paths

Module paths 

Source
Expand description

File path validation and normalization.

Cross-platform guards against path traversal, Windows reserved device names, forbidden characters, Unicode NFC drift (macOS NFD vs Linux NFC), and legacy Windows MAX_PATH (260) limits without the \\?\ prefix.

Constants§

MAX_CONFIG_TOML_BYTES
Cap for config.toml (local agent registry — not a multi-tenant store).
MAX_KNOWN_HOSTS_BYTES
Cap for TOFU known_hosts text file.
MAX_SECRETS_KEY_FILE_BYTES
Default cap for primary-key files (hex is 64 chars; allow whitespace/BOM).
WINDOWS_MAX_COMPONENT
Maximum length of a single path component on Windows (excluding separators).
WINDOWS_MAX_PATH
Legacy Windows MAX_PATH including the trailing NUL (Win32 default without long-path prefix).

Functions§

has_windows_long_path_prefix
Returns true when path uses the Windows extended-length prefix (\\?\ or //?/).
normalize_nfc
Normalizes a file name to Unicode NFC form.
read_text_capped
Reads a UTF-8 text file with a hard byte cap (memory / OOM hygiene).
validate_and_normalize
Validates and normalizes a file name in one operation.
validate_local_path_length
Validates a local filesystem path against Windows legacy length limits.
validate_name
Validates a file name (no path separators).
validate_no_traversal
Validates that a path has no traversal components.
xdg_config_dir
Resolves the XDG config directory for crate::constants::APP_NAME.