File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -583,8 +583,16 @@ impl MainHandler {
583583 let headers = & field. headers ;
584584 let mut target_path = path. to_owned ( ) ;
585585
586- let raw_filename = headers. filename . clone ( ) . unwrap ( ) ;
587- let filename = Path :: new ( & raw_filename) . file_name ( ) . unwrap ( ) ;
586+ let Some ( raw_filename) = headers. filename . clone ( ) else {
587+ println ! ( "[Warning]: Skipping field with no filename" ) ;
588+ continue ;
589+ } ;
590+
591+ let Some ( filename) = Path :: new ( & raw_filename) . file_name ( ) else {
592+ println ! ( "[Warning]: Invalid filename: {raw_filename}" ) ;
593+ continue ;
594+ } ;
595+
588596 target_path. push ( filename) ;
589597 if let Err ( errno) = std:: fs:: File :: create ( target_path)
590598 . and_then ( |mut file| io:: copy ( & mut data, & mut file) )
@@ -594,7 +602,7 @@ impl MainHandler {
594602 format ! ( "Copy file failed: {errno}" ) ,
595603 ) ) ;
596604 } else {
597- println ! ( " >> File saved: {}" , headers . filename . clone ( ) . unwrap ( ) ) ;
605+ println ! ( " >> File saved: {raw_filename}" ) ;
598606 }
599607 }
600608 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments