#49: Filter out unprintable characters

This commit is contained in:
mtkennerly 2024-08-17 19:01:57 -04:00
parent 8c2be97d3b
commit d907d5a5a3
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
4 changed files with 14 additions and 33 deletions

View file

@ -135,5 +135,12 @@ fn too_broad(path: &str) -> bool {
}
pub fn usable(path: &str) -> bool {
!path.is_empty() && !path.contains("{{") && !path.starts_with("./") && !path.starts_with("../") && !too_broad(path)
static UNPRINTABLE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\p{Cc}|\p{Cf})").unwrap());
!path.is_empty()
&& !path.contains("{{")
&& !path.starts_with("./")
&& !path.starts_with("../")
&& !too_broad(path)
&& !UNPRINTABLE.is_match(path)
}