This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch http-4.x
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/http-4.x by this push:
     new b77d885da1 FELIX-6595 : Update to Commons Fileupload 1.5
b77d885da1 is described below

commit b77d885da120ac941ec0a5bbcc19e43605a3b0c9
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Tue Feb 21 11:01:09 2023 +0100

    FELIX-6595 : Update to Commons Fileupload 1.5
---
 .../http/base/internal/dispatch/MultipartConfig.java  | 19 ++++++++++++++++---
 .../base/internal/dispatch/ServletRequestWrapper.java |  1 +
 .../http/base/internal/handler/ServletHandler.java    |  5 +++--
 .../felix/http/base/internal/runtime/ServletInfo.java |  3 ++-
 http/bridge/pom.xml                                   |  2 +-
 http/itest/pom.xml                                    |  2 +-
 http/jetty/pom.xml                                    |  2 +-
 7 files changed, 25 insertions(+), 9 deletions(-)

diff --git 
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/MultipartConfig.java
 
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/MultipartConfig.java
index 42e04caa73..2c19cfe545 100644
--- 
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/MultipartConfig.java
+++ 
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/MultipartConfig.java
@@ -20,9 +20,9 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 
 public final class MultipartConfig
 {
-    public static final MultipartConfig DEFAULT_CONFIG = new 
MultipartConfig(null, null, -1, -1);
+    public static final MultipartConfig DEFAULT_CONFIG = new 
MultipartConfig(null, null, -1, -1, -1);
 
-    public static final MultipartConfig INVALID_CONFIG = new 
MultipartConfig(null, null, -1, -1);
+    public static final MultipartConfig INVALID_CONFIG = new 
MultipartConfig(null, null, -1, -1, -1);
 
     /**
      * Specifies the multipart threshold
@@ -44,10 +44,16 @@ public final class MultipartConfig
      */
     public final long multipartMaxRequestSize;
 
+    /**
+     * Specifies the multipart max files
+     */
+    public final long multipartMaxFileCount;
+
     public MultipartConfig(final Integer threshold,
             final String location,
             final long maxFileSize,
-            final long maxRequestSize)
+            final long maxRequestSize,
+            final long maxFileCount)
     {
         if ( threshold != null && threshold > 0)
         {
@@ -72,5 +78,12 @@ public final class MultipartConfig
         {
             this.multipartMaxRequestSize = -1;
         }
+        if ( maxFileCount > 0 ) {
+            this.multipartMaxFileCount = maxFileCount;
+        }
+        else
+        {
+            this.multipartMaxFileCount = 50;
+        }
     }
 }
diff --git 
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
 
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
index 0c676c5705..18158bb6e6 100644
--- 
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
+++ 
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
@@ -435,6 +435,7 @@ final class ServletRequestWrapper extends 
HttpServletRequestWrapper
         upload.setFileSizeMax(this.multipartConfig.multipartMaxFileSize);
         upload.setFileItemFactory(new 
DiskFileItemFactory(this.multipartConfig.multipartThreshold,
                 new File(this.multipartConfig.multipartLocation)));
+        upload.setFileCountMax(this.multipartConfig.multipartMaxFileCount);
 
         // Parse the request
         List<FileItem> items = null;
diff --git 
a/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java
 
b/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java
index 9a3f2b34d9..8f29c46eeb 100644
--- 
a/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java
+++ 
b/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java
@@ -83,8 +83,9 @@ public abstract class ServletHandler implements 
Comparable<ServletHandler>
             this.mpConfig = new MultipartConfig(origConfig.multipartThreshold,
                     location,
                     origConfig.multipartMaxFileSize,
-                    origConfig.multipartMaxRequestSize);
-        }
+                    origConfig.multipartMaxRequestSize,
+                    origConfig.multipartMaxFileCount);
+            }
         else
         {
             this.mpConfig = null;
diff --git 
a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java
 
b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java
index 59724dba0e..ae1114b7cf 100644
--- 
a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java
+++ 
b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java
@@ -95,7 +95,8 @@ public class ServletInfo extends 
WhiteboardServiceInfo<Servlet>
                 cfg = new MultipartConfig(getIntProperty(ref, 
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_MULTIPART_FILESIZETHRESHOLD),
                         getStringProperty(ref, 
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_MULTIPART_LOCATION),
                         getLongProperty(ref, 
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXFILESIZE),
-                        getLongProperty(ref, 
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXREQUESTSIZE));
+                        getLongProperty(ref, 
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXREQUESTSIZE),
+                        getLongProperty(ref, 
"osgi.http.whiteboard.servlet.multipart.maxFileCount"));
             }
             catch (final IllegalArgumentException iae)
             {
diff --git a/http/bridge/pom.xml b/http/bridge/pom.xml
index 1cfac7d0a7..7d1f51658b 100644
--- a/http/bridge/pom.xml
+++ b/http/bridge/pom.xml
@@ -142,7 +142,7 @@
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.http.base</artifactId>
-            <version>4.2.2</version>
+            <version>4.2.4</version>
         </dependency>
     </dependencies>
 
diff --git a/http/itest/pom.xml b/http/itest/pom.xml
index 24aded3cb5..54212ea0cc 100644
--- a/http/itest/pom.xml
+++ b/http/itest/pom.xml
@@ -35,7 +35,7 @@
         <pax.exam.version>4.13.1</pax.exam.version>
         <pax.url.aether.version>2.6.2</pax.url.aether.version>
         <http.servlet.api.version>2.0.0</http.servlet.api.version>
-        <http.jetty.version>5.0.0-SNAPSHOT</http.jetty.version>
+        <http.jetty.version>4.2.7-SNAPSHOT</http.jetty.version>
     </properties>
 
     <build>
diff --git a/http/jetty/pom.xml b/http/jetty/pom.xml
index 39b6f7f1dd..cd6c37b69a 100644
--- a/http/jetty/pom.xml
+++ b/http/jetty/pom.xml
@@ -400,7 +400,7 @@
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.http.base</artifactId>
-            <version>4.2.2</version>
+            <version>4.2.4</version>
         </dependency>
         <dependency>
             <groupId>commons-fileupload</groupId>

Reply via email to