validate filename

This commit is contained in:
postscriptum 2025-07-05 10:33:00 +03:00
parent e60c8cf724
commit afd71fa435

View file

@ -11,7 +11,7 @@ use source::Source;
use std::{
collections::{HashMap, HashSet},
fs,
path::PathBuf,
path::{MAIN_SEPARATOR, PathBuf},
str::FromStr,
};
use template::Template;
@ -35,6 +35,13 @@ impl Nex {
(is_cleanup, is_debug): (bool, bool),
user_names: &Vec<String>,
) -> Result<Self> {
// validate filename
if filename
.trim_matches(MAIN_SEPARATOR)
.contains(MAIN_SEPARATOR)
{
bail!("File name should not contain subdir `{MAIN_SEPARATOR}` separator!")
}
// init data export location
let target = PathBuf::from_str(&target_dir)?.canonicalize()?;
if !target.is_dir() {