Repository: primefaces/primefaces (java)

Issue:
FileUpload: tests fail when path contains a empty space
Windows 10, FileUploadUtilsTest#requireValidFilePath_AbsoluteFile:

Expected :Invalid directory, name does not match the canonical path.
Actual   :Invalid path: /D:/Development/OS%20Projects/primefaces/primefaces/target/test-classes/test.png


Pull request description:
Fix #11134: FileUpload unescape proper URL chars
Fix #11134: FileUpload unescape proper URL chars

Patch:
diff --git a/primefaces/src/main/java/org/primefaces/util/FileUploadUtils.java b/primefaces/src/main/java/org/primefaces/util/FileUploadUtils.java
index a827902416..f06c5591e6 100644
--- a/primefaces/src/main/java/org/primefaces/util/FileUploadUtils.java
+++ b/primefaces/src/main/java/org/primefaces/util/FileUploadUtils.java
@@ -24,6 +24,8 @@
 package org.primefaces.util;
 
 import java.io.*;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -102,6 +104,7 @@ public class FileUploadUtils {
             throw validationError("Invalid path: (" + filePath + ") contains unprintable character: " + ch);
         }
 
+        filePath = URLDecoder.decode(filePath, StandardCharsets.UTF_8);
         if (PERCENTS_PAT.matcher(filePath).find()) {
             throw validationError("Invalid path: " + filePath);
         }


Test patch:
diff --git a/primefaces/src/test/java/org/primefaces/util/FileUploadUtilsTest.java b/primefaces/src/test/java/org/primefaces/util/FileUploadUtilsTest.java
index 9ca37091d3..9d9ad244dd 100644
--- a/primefaces/src/test/java/org/primefaces/util/FileUploadUtilsTest.java
+++ b/primefaces/src/test/java/org/primefaces/util/FileUploadUtilsTest.java
@@ -175,6 +175,31 @@ class FileUploadUtilsTest {
         }
     }
 
+    @Test
+    void requireValidFilePath_AbsoluteFileWithWindowsSpaces() {
+        // Unix systems can start with / but Windows cannot
+        String os = System.getProperty("os.name").toLowerCase();
+
+        // Arrange
+        String relativePath = "/D:/Development/OS%20Projects/primefaces/primefaces/target/test-classes/test.png";
+
+        // Act
+        if (os.contains("win")) {
+            try {
+                FileUploadUtils.requireValidFilePath(relativePath, false);
+                fail("File was absolute path and should have failed");
+            }
+            catch (ValidatorException e) {
+                // Assert
+                assertEquals("Invalid directory, name does not match the canonical path.", e.getFacesMessage().getDetail());
+            }
+        }
+        else {
+            String result = FileUploadUtils.requireValidFilePath(relativePath, false);
+            assertTrue(result.endsWith("test.png"));
+        }
+    }
+
     @Test
     void requireValidFilePath_PathTraversal() {
         // Arrange