You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2020/09/09 10:58:09 UTC

[struts] branch struts-2-5-x updated: Empty file upload, storeLocation null gives wrong error message.

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

lukaszlenart pushed a commit to branch struts-2-5-x
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/struts-2-5-x by this push:
     new 1efcc93  Empty file upload, storeLocation null gives wrong error message.
     new e60df05  Merge pull request #437 from gregh3269/struts-2-5-x
1efcc93 is described below

commit 1efcc938cfd4674db7fa16b260d17e574b4842fc
Author: Greg Huber <gh...@guestales.co.uk>
AuthorDate: Fri Sep 4 13:23:15 2020 +0100

    Empty file upload, storeLocation null gives wrong error message.
---
 .../org/apache/struts2/interceptor/FileUploadInterceptor.java     | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
index b6a0fa9..2dba508 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
@@ -346,6 +346,14 @@ public class FileUploadInterceptor extends AbstractInterceptor {
             if (LOG.isWarnEnabled()) {
                 LOG.warn(errMsg);
             }
+        } else if (file.getContent() == null) {
+            String errMsg = getTextMessage(action, "struts.messages.error.uploading", new String[]{filename});
+            if (validation != null) {
+                validation.addFieldError(inputName, errMsg);
+            }
+            if (LOG.isWarnEnabled()) {
+                LOG.warn(errMsg);
+            }
         } else if (maximumSize != null && maximumSize < file.length()) {
             String errMsg = getTextMessage(action, "struts.messages.error.file.too.large", new String[]{inputName, filename, file.getName(), "" + file.length(), getMaximumSizeStr(action)});
             if (validation != null) {