3030import de .rwth .idsg .steve .web .dto .EndpointInfo ;
3131import de .rwth .idsg .steve .web .dto .SettingsForm ;
3232import lombok .RequiredArgsConstructor ;
33+ import org .apache .commons .lang3 .StringUtils ;
3334import org .joda .time .DateTime ;
3435import org .joda .time .DateTimeZone ;
3536import org .springframework .http .HttpHeaders ;
@@ -135,7 +136,7 @@ public void exportZip(@ModelAttribute("exportForm") DataExportForm exportForm,
135136 HttpServletResponse response ) throws IOException {
136137 String fileName = "data-export_" + System .currentTimeMillis () + ".zip" ;
137138 String headerKey = "Content-Disposition" ;
138- String headerValue = String . format ( "attachment; filename=\" %s\" " , fileName );
139+ String headerValue = "attachment; filename=\" %s\" " . formatted ( fileName );
139140 response .setHeader (headerKey , headerValue );
140141 response .setContentType ("application/zip" );
141142
@@ -148,7 +149,13 @@ public String importZip(@RequestParam("file") MultipartFile file, Model model) t
148149 throw new SteveException .BadRequest ("File is empty" );
149150 }
150151
151- if (!file .getOriginalFilename ().endsWith (".zip" )) {
152+ String fileName = file .getOriginalFilename ();
153+
154+ if (StringUtils .isEmpty (fileName )) {
155+ throw new SteveException .BadRequest ("File name is empty" );
156+ }
157+
158+ if (!fileName .endsWith (".zip" )) {
152159 throw new SteveException .BadRequest ("File must be a ZIP archive" );
153160 }
154161
0 commit comments