mirror of
https://codeberg.org/postscriptum/snac2nex.git
synced 2026-03-31 21:25:28 +00:00
validate filename
This commit is contained in:
parent
e60c8cf724
commit
afd71fa435
1 changed files with 8 additions and 1 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue