diff --git a/src/main.rs b/src/main.rs index 992377e..52a4198 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1222,9 +1222,8 @@ pub struct Args { /// to the data and the MIME type 'png' will be attached to it. /// Furthermore, '-' can only be used once. #[arg(short, long, num_args(0..), )] - file: Vec, + file: Vec, - // Todo: change this Vec to Vec for --file /// Specify the message type as Notice. /// Details:: /// There are 3 message types for '--message'. @@ -3014,11 +3013,15 @@ pub(crate) async fn cli_file(client: &Client, ap: &Args) -> Result<(), Error> { } let mut files: Vec = Vec::new(); for filename in &ap.file { - match filename.as_str() { - "" => info!("Skipping empty file name."), - r"-" => files.push(PathBuf::from("-".to_string())), - r"\-" => files.push(PathBuf::from(r"\-".to_string())), - _ => files.push(PathBuf::from(filename)), + match filename.to_str() { + Some("") => info!("Skipping empty file name."), + Some(r"-") => files.push(PathBuf::from("-")), + Some(r"\-") => files.push(PathBuf::from(r"\-")), + Some(_) => files.push(filename.clone()), + None => { + warn!("Skipping file with invalid UTF-8 path: {:?}", filename); + continue; + } } } // pb: label to attach to a stdin pipe data in case there is data piped in from stdin