From 5dc0a25b26f3ccb88575c75d47ae53e4ba34009d Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <104101892+pixeebot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 20:44:19 +0000 Subject: [PATCH] Sanitized user-provided file names in HTTP multipart uploads --- .../software/SPDF/controller/api/misc/OCRController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java index 150468c9..b2601ec5 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java @@ -1,6 +1,7 @@ package stirling.software.SPDF.controller.api.misc; import io.github.pixee.security.BoundedLineReader; +import io.github.pixee.security.Filenames; import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.File; @@ -175,7 +176,7 @@ public class OCRController { // Read the final PDF file byte[] pdfContent = Files.readAllBytes(finalOutputFile); String outputFilename = - inputFile.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_OCR.pdf"; + Filenames.toSimpleFileName(inputFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_OCR.pdf"; return ResponseEntity.ok() .header(