fix bug allowing invalid characters in pdf name

This commit is contained in:
Bernaldo Mihasi 2022-12-08 13:04:55 +02:00
parent 572be373e5
commit ad00695d4e
1 changed files with 1 additions and 1 deletions

View File

@ -2142,7 +2142,7 @@ public class DataManagementPlanManager {
throw new Exception("DMP already has a DOI");*/
FileEnvelope file = getWordDocument(depositRequest.getDmpId(), principal, configLoader);
String name = file.getFilename().substring(0, file.getFilename().length() - 5).replace(" ", "_").replace(",", "_");
String name = file.getFilename().substring(0, file.getFilename().length() - 5).replaceAll("[^a-zA-Z0-9_+ ]", "").replace(" ", "_").replace(",", "_");
File pdfFile = PDFUtils.convertToPDF(file, environment);
String fileName = name + ".pdf";
ResponseEntity<byte[]> jsonFile;