use crate::core::error::{ConfigError, Result};
pub fn is_plain_file_name(value: &str) -> bool {
is_safe_path_component(value)
}
pub fn is_safe_path_component(value: &str) -> bool {
!value.is_empty()
&& value != "."
&& value != ".."
&& !value.contains('/')
&& !value.contains('\\')
&& !value.contains(':')
&& !value.chars().any(char::is_control)
}
pub fn validate_plain_file_name(value: &str) -> Result<&str> {
if is_plain_file_name(value) {
Ok(value)
} else {
Err(ConfigError::InvalidPathComponent(value.to_string()))
}
}
pub fn validate_path_component(value: &str) -> Result<&str> {
if is_safe_path_component(value) {
Ok(value)
} else {
Err(ConfigError::InvalidPathComponent(value.to_string()))
}
}