pub fn is_safe_path_component(s: &str) -> boolExpand description
Returns true only when s is a single, non-traversal path component that is
valid on all supported platforms.
Use this to validate untrusted segments (app ids, environment names, etc.) before joining them into a path.
Rejects:
- empty strings,
., and.. - strings containing
/or\(path separators on any platform) - Windows-forbidden filename characters:
: * ? " < > | - ASCII control characters (bytes 0x00–0x1F) and the DEL character (0x7F)
- leading or trailing space (leading space is invisible in directory listings)
- trailing
.(valid on Unix but rejected by Windows) - Windows reserved device names (
CON,NUL,COM1, etc.) with or without extension