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::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
fs,
|
fs,
|
||||||
path::PathBuf,
|
path::{MAIN_SEPARATOR, PathBuf},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
use template::Template;
|
use template::Template;
|
||||||
|
|
@ -35,6 +35,13 @@ impl Nex {
|
||||||
(is_cleanup, is_debug): (bool, bool),
|
(is_cleanup, is_debug): (bool, bool),
|
||||||
user_names: &Vec<String>,
|
user_names: &Vec<String>,
|
||||||
) -> Result<Self> {
|
) -> 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
|
// init data export location
|
||||||
let target = PathBuf::from_str(&target_dir)?.canonicalize()?;
|
let target = PathBuf::from_str(&target_dir)?.canonicalize()?;
|
||||||
if !target.is_dir() {
|
if !target.is_dir() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue