diff --git a/pass-core-file-service/src/main/java/org/eclipse/pass/file/service/PassFileServiceController.java b/pass-core-file-service/src/main/java/org/eclipse/pass/file/service/PassFileServiceController.java index 7256123..b34ee32 100644 --- a/pass-core-file-service/src/main/java/org/eclipse/pass/file/service/PassFileServiceController.java +++ b/pass-core-file-service/src/main/java/org/eclipse/pass/file/service/PassFileServiceController.java @@ -103,11 +103,14 @@ public ResponseEntity fileUpload(@RequestParam("file") MultipartFile file, Pr @ResponseBody public ResponseEntity getFileById(@PathVariable("uuid") String uuid, @PathVariable("origFileName") String origFileName) { - String fileId = uuid + "/" + origFileName; if (StringUtils.isEmpty(uuid) || StringUtils.isEmpty(origFileName)) { LOG.error("File ID not provided to get a file."); return ResponseEntity.badRequest().body("File ID not provided to get a file."); } + String cleansedUuid = StringUtils.normalizeSpace(uuid); + String cleansedOrigFileName = StringUtils.normalizeSpace(origFileName); + String fileId = cleansedUuid + "/" + cleansedOrigFileName; + ByteArrayResource fileResource; String contentType = ""; @@ -141,7 +144,9 @@ public ResponseEntity deleteFileById(@PathVariable("uuid") String uuid, @PathVariable("origFileName") String origFileName, Principal principal, HttpServletRequest request) { String principalName = principal.getName(); - String fileId = uuid + "/" + origFileName; + String cleansedUuid = StringUtils.normalizeSpace(uuid); + String cleansedOrigFileName = StringUtils.normalizeSpace(origFileName); + String fileId = cleansedUuid + "/" + cleansedOrigFileName; //Get the file, check that it exists, and then check if current user has permissions to delete try { diff --git a/pass-core-file-service/src/main/java/org/eclipse/pass/file/service/storage/FileStorageService.java b/pass-core-file-service/src/main/java/org/eclipse/pass/file/service/storage/FileStorageService.java index 811539f..c85323b 100644 --- a/pass-core-file-service/src/main/java/org/eclipse/pass/file/service/storage/FileStorageService.java +++ b/pass-core-file-service/src/main/java/org/eclipse/pass/file/service/storage/FileStorageService.java @@ -172,7 +172,7 @@ public ByteArrayResource getFile(String fileId) throws IOException { } // the output path for getObject must not exist, hence temp dir is created on the fly ocflRepository.getObject(ObjectVersionId.head(fileId), tempLoadDir); - LOG.debug("File Service: File with ID " + fileId + " was loaded from the repo"); + LOG.debug("File Service: File with ID {} was loaded from the repo", fileId); Path fileNamePath = Objects.requireNonNull(tempLoadDir.toFile().listFiles())[0].toPath(); loadedResource = new ByteArrayResource(Files.readAllBytes(fileNamePath));