struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amashche...@apache.org
Subject [1/3] struts git commit: WW-4583 JakartaStreamMultiPartRequest fails on short file name and on empty file input
Date Wed, 06 Jan 2016 17:32:33 GMT
Repository: struts
Updated Branches:
  refs/heads/master 4f29d8861 -> a4f8d4921
  refs/heads/support-2-3 bf46145ba -> b448d7995


WW-4583 JakartaStreamMultiPartRequest fails on short file name and on empty file input


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/a4f8d492
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/a4f8d492
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/a4f8d492

Branch: refs/heads/master
Commit: a4f8d492144a62af2a7d5e934e62d737bdfc8058
Parents: 4f29d88
Author: Aleksandr Mashchenko <amashchenko@apache.org>
Authored: Wed Jan 6 19:24:56 2016 +0200
Committer: Aleksandr Mashchenko <amashchenko@apache.org>
Committed: Wed Jan 6 19:24:56 2016 +0200

----------------------------------------------------------------------
 .../multipart/JakartaStreamMultiPartRequest.java          | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/a4f8d492/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
index 6727f3e..f4c4665 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
@@ -384,6 +384,12 @@ public class JakartaStreamMultiPartRequest implements MultiPartRequest
{
      * @param location location
      */
     private void processFileItemStreamAsFileField(FileItemStream itemStream, String location)
{
+        // Skip file uploads that don't have a file name - meaning that no file was selected.
+        if (itemStream.getName() == null || itemStream.getName().trim().length() < 1)
{
+            LOG.debug("No file has been uploaded for the field: {}", itemStream.getFieldName());
+            return;
+        }
+
         File file = null;
         try {
             // Create the temporary upload file.
@@ -424,6 +430,10 @@ public class JakartaStreamMultiPartRequest implements MultiPartRequest
{
             suffix = name.substring(name.lastIndexOf('.'));
         }
 
+        if (prefix.length() < 3) {
+            prefix = UUID.randomUUID().toString();
+        }
+
         File file = File.createTempFile(prefix + "_", suffix, new File(location));
         LOG.debug("Creating temporary file '{}' (originally '{}').", file.getName(), fileName);
         return file;


Mime
View raw message