Only allow alphanumeric and dots for entrynames
This commit is contained in:
parent
aaa6670eda
commit
ac315529b3
@ -262,7 +262,7 @@ fn exec(entryname: &str, cmdargs: &Vec<String>) -> std::io::Result<()> {
|
|||||||
"Specified entry is outside base directory",
|
"Specified entry is outside base directory",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if ! p.is_file() {
|
if !p.is_file() {
|
||||||
return Err(std::io::Error::new(
|
return Err(std::io::Error::new(
|
||||||
ErrorKind::Other,
|
ErrorKind::Other,
|
||||||
"Error: Entry not a file",
|
"Error: Entry not a file",
|
||||||
@ -324,7 +324,12 @@ fn main() -> Result<(), std::io::Error> {
|
|||||||
let cmdargs: Vec<String> = argv.collect();
|
let cmdargs: Vec<String> = argv.collect();
|
||||||
let entryname = cmdargs.get(1);
|
let entryname = cmdargs.get(1);
|
||||||
if entryname.is_some() {
|
if entryname.is_some() {
|
||||||
match exec(&entryname.unwrap(), &cmdargs) {
|
let entry = entryname.unwrap();
|
||||||
|
if !entry.chars().all(|c| c.is_alphanumeric() || c == '.') {
|
||||||
|
eprintln!("Entry names can only contain alphanumeric characters and dots");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
match exec(entry, &cmdargs) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("The following error ocurred:");
|
eprintln!("The following error ocurred:");
|
||||||
eprintln!("{}", e);
|
eprintln!("{}", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user