From 3b02d91fddad73c2cd57f9d7c7f4b83809ef3d62 Mon Sep 17 00:00:00 2001 From: Mobb autofixer Date: Thu, 15 Aug 2024 19:20:25 +0000 Subject: [PATCH] mobb fix commit: aa8959cd-922a-488d-9429-9f748e5f0c4c --- .../microfocus/example/service/FileSystemStorageService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/microfocus/example/service/FileSystemStorageService.java b/src/main/java/com/microfocus/example/service/FileSystemStorageService.java index a5a6197b..45cb178b 100644 --- a/src/main/java/com/microfocus/example/service/FileSystemStorageService.java +++ b/src/main/java/com/microfocus/example/service/FileSystemStorageService.java @@ -51,7 +51,7 @@ public void store(MultipartFile file) { throw new StorageException("Failed to store empty file."); } Path destinationFile = this.rootLocation.resolve( - Paths.get(file.getOriginalFilename())) + Paths.get(String.valueOf(file.getOriginalFilename()).replaceAll("([/\\\\:*?\"<>|])|(^\\s)|([.\\s]$)", "_").replaceAll("\0", ""))) .normalize().toAbsolutePath(); if (!destinationFile.getParent().equals(this.rootLocation.toAbsolutePath())) { // This is a security check