[struts] branch WW-5285-max-files created (now ca637ef70)

2023-02-25 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a change to branch WW-5285-max-files
in repository https://gitbox.apache.org/repos/asf/struts.git


  at ca637ef70 WW-5285 Limits max number of files to upload at once 
Upgrades commons-fileupload to ver. 1.5 and sets default limit to 256 files

This branch includes the following new commits:

 new ca637ef70 WW-5285 Limits max number of files to upload at once 
Upgrades commons-fileupload to ver. 1.5 and sets default limit to 256 files

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.




[struts] 01/01: WW-5285 Limits max number of files to upload at once Upgrades commons-fileupload to ver. 1.5 and sets default limit to 256 files

2023-02-25 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch WW-5285-max-files
in repository https://gitbox.apache.org/repos/asf/struts.git

commit ca637ef70ccecfc22b6549d8faf78110be17e51e
Author: Lukasz Lenart 
AuthorDate: Sat Feb 25 10:42:21 2023 +0100

WW-5285 Limits max number of files to upload at once
Upgrades commons-fileupload to ver. 1.5 and sets default limit to 256 files
---
 .../java/org/apache/struts2/StrutsConstants.java   |  3 ++
 .../struts2/config/entities/ConstantConfig.java| 10 +
 .../multipart/AbstractMultiPartRequest.java| 12 ++
 .../multipart/JakartaMultiPartRequest.java | 21 ---
 .../multipart/JakartaStreamMultiPartRequest.java   |  3 ++
 .../org/apache/struts2/default.properties  |  1 +
 .../org/apache/struts2/struts-messages.properties  |  1 +
 .../interceptor/FileUploadInterceptorTest.java | 44 ++
 pom.xml|  2 +-
 9 files changed, 91 insertions(+), 6 deletions(-)

diff --git a/core/src/main/java/org/apache/struts2/StrutsConstants.java 
b/core/src/main/java/org/apache/struts2/StrutsConstants.java
index 9a1920f02..477c35f23 100644
--- a/core/src/main/java/org/apache/struts2/StrutsConstants.java
+++ b/core/src/main/java/org/apache/struts2/StrutsConstants.java
@@ -142,6 +142,9 @@ public final class StrutsConstants {
 /** The maximize size of a multipart request (file upload) */
 public static final String STRUTS_MULTIPART_MAXSIZE = 
"struts.multipart.maxSize";
 
+/** The maximized number of files allowed to upload */
+public static final String STRUTS_MULTIPART_MAXFILES = 
"struts.multipart.maxFiles";
+
 /** The directory to use for storing uploaded files */
 public static final String STRUTS_MULTIPART_SAVEDIR = 
"struts.multipart.saveDir";
 
diff --git 
a/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java 
b/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java
index 0fe1e300c..107f35e51 100644
--- a/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java
+++ b/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java
@@ -64,6 +64,7 @@ public class ConstantConfig {
 private String uiTheme;
 private String uiThemeExpansionToken;
 private Long multipartMaxSize;
+private Long multipartMaxFiles;
 private String multipartSaveDir;
 private Integer multipartBufferSize;
 private BeanConfig multipartParser;
@@ -195,6 +196,7 @@ public class ConstantConfig {
 map.put(StrutsConstants.STRUTS_UI_THEME, uiTheme);
 map.put(StrutsConstants.STRUTS_UI_THEME_EXPANSION_TOKEN, 
uiThemeExpansionToken);
 map.put(StrutsConstants.STRUTS_MULTIPART_MAXSIZE, 
Objects.toString(multipartMaxSize, null));
+map.put(StrutsConstants.STRUTS_MULTIPART_MAXFILES, 
Objects.toString(multipartMaxFiles, null));
 map.put(StrutsConstants.STRUTS_MULTIPART_SAVEDIR, multipartSaveDir);
 map.put(StrutsConstants.STRUTS_MULTIPART_BUFFERSIZE, 
Objects.toString(multipartBufferSize, null));
 map.put(StrutsConstants.STRUTS_MULTIPART_PARSER, 
beanConfToString(multipartParser));
@@ -579,6 +581,14 @@ public class ConstantConfig {
 this.multipartMaxSize = multipartMaxSize;
 }
 
+public Long getMultipartMaxFiles() {
+return multipartMaxFiles;
+}
+
+public void setMultipartMaxFiles(Long multipartMaxFiles) {
+this.multipartMaxFiles = multipartMaxFiles;
+}
+
 public String getMultipartSaveDir() {
 return multipartSaveDir;
 }
diff --git 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequest.java
 
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequest.java
index 700364047..b3410e578 100644
--- 
a/core/src/main/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequest.java
+++ 
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequest.java
@@ -54,6 +54,12 @@ public abstract class AbstractMultiPartRequest implements 
MultiPartRequest {
 protected long maxSize;
 protected boolean maxSizeProvided;
 
+/**
+ * Specifies the maximum number of files in one request.
+ */
+protected long maxFiles;
+protected boolean maxFilesProvided;
+
 /**
  * Specifies the buffer size to use during streaming.
  */
@@ -88,6 +94,12 @@ public abstract class AbstractMultiPartRequest implements 
MultiPartRequest {
 this.maxSize = Long.parseLong(maxSize);
 }
 
+@Inject(StrutsConstants.STRUTS_MULTIPART_MAXFILES)
+public void setMaxFiles(String maxFiles) {
+this.maxFilesProvided = true;
+this.maxFiles = Long.parseLong(maxFiles);
+}
+
 @Inject
 public void setLocaleProviderFactory(LocaleProviderFactory 
localeProviderFactory) {
 defaultLocale = 
localeProviderFactory.createLocalePro