Skip to main content

is_safe_path_component

Function is_safe_path_component 

Source
pub fn is_safe_path_component(value: &str) -> bool
Expand description

Returns true when value is safe to append as one path component.

This also rejects Windows reserved device names (CON, PRN, AUX, NUL, COM1-COM9, LPT1-LPT9, case-insensitively, including with an extension such as NUL.txt) on every platform, not just Windows – consistent with this function’s existing OS-independent behavior. On Windows these names refer to devices rather than files in any directory, so a value that passes here but is later used as a file name would fail, or silently target a device, only there.