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_hoststext 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_PATHincluding the trailing NUL (Win32 default without long-path prefix).
Functions§
- has_
windows_ long_ path_ prefix - Returns
truewhenpathuses 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.