You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by sw...@apache.org on 2019/04/24 10:05:12 UTC

svn commit: r1858036 - in /ofbiz/ofbiz-framework/branches/release18.12: ./ framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java

Author: swapnilmmane
Date: Wed Apr 24 10:05:12 2019
New Revision: 1858036

URL: http://svn.apache.org/viewvc?rev=1858036&view=rev
Log:
Applied fix from trunk for revision: 1858035 
===

Fixed: Parameters are not available to the next response type when form of enctype=multipart/form-data type is submitted
(OFBIZ-10833)

Reason: The UtilHttp.getMultiPartParameterMap method is used to get the parameters in case of multipart/form-data type.
The getMultiPartParameterMap parse the request to get the parameters.

{code}
uploadedItems = UtilGenerics.<FileItem>checkList(upload.parseRequest(request));
{code}

As per the Apache commons-fileupload guideline, a request can only be parsed once [1]. So, for the next response, again the same getMultiPartParameterMap method is executed (with the same request object), and no parameters are found, since, the request is already parsed.

Also, have a look at the StackOverflow question [2], it also contains related information.

Fix for the issue:
Set the consumed parameters (except uploaded file(s)) in the request attribute so that it will be available to the next response.
The uploaded file(s) are not set in request attribute again to avoid unnecessary memory consumption, also it makes no sense to traverse the uploaded file in the request.

[1] http://commons.apache.org/proper/commons-fileupload/faq.html#empty-parse

[2] https://stackoverflow.com/questions/13881272/servletfileuploadparserequestrequest-returns-an-empty-list

Thanks: Ingo Wolfmayr for reporting issue and Jacques Le Roux for review.


Modified:
    ofbiz/ofbiz-framework/branches/release18.12/   (props changed)
    ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java

Propchange: ofbiz/ofbiz-framework/branches/release18.12/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Apr 24 10:05:12 2019
@@ -10,4 +10,4 @@
 /ofbiz/branches/json-integration-refactoring:1634077-1635900
 /ofbiz/branches/multitenant20100310:921280-927264
 /ofbiz/branches/release13.07:1547657
-/ofbiz/ofbiz-framework/trunk:1849931,1850015,1850023,1850530,1850647,1850685,1850694,1850711,1850914,1850918,1850921,1850948,1850953,1851006,1851013,1851068,1851074,1851130,1851158,1851200,1851224,1851247,1851254,1851315,1851319,1851350,1851353,1851433,1851500,1851805,1851885,1851998,1852503,1852587,1852818,1852882,1853070,1853109,1853691,1853745,1853750,1854306,1854457,1854683,1855078,1855083,1855287,1855371,1855403,1855488,1855492,1855497,1855501,1855898,1856212,1856405,1856455,1856459-1856460,1856484,1856598,1856610,1856613,1856617,1856667,1857099,1857152,1857154,1857173,1857180,1857213,1857392,1857617,1857692,1857813
+/ofbiz/ofbiz-framework/trunk:1849931,1850015,1850023,1850530,1850647,1850685,1850694,1850711,1850914,1850918,1850921,1850948,1850953,1851006,1851013,1851068,1851074,1851130,1851158,1851200,1851224,1851247,1851254,1851315,1851319,1851350,1851353,1851433,1851500,1851805,1851885,1851998,1852503,1852587,1852818,1852882,1853070,1853109,1853691,1853745,1853750,1854306,1854457,1854683,1855078,1855083,1855287,1855371,1855403,1855488,1855492,1855497,1855501,1855898,1856212,1856405,1856455,1856459-1856460,1856484,1856598,1856610,1856613,1856617,1856667,1857099,1857152,1857154,1857173,1857180,1857213,1857392,1857617,1857692,1857813,1858035

Modified: ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java?rev=1858036&r1=1858035&r2=1858036&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java (original)
+++ ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java Wed Apr 24 10:05:12 2019
@@ -257,6 +257,10 @@ public final class UtilHttp {
                                 multiPartMap.put(fieldName, item.getString());
                             }
                         }
+                        /* OFBIZ-10833 - Set the consumed parameters in request attributes for enctype="multipart/form-data" type form
+                         * so that it will be available for the next response. Please refer Jira for more details.
+                         */
+                        request.setAttribute(fieldName, multiPartMap.get(fieldName));
                     } else {
                         String fileName = item.getName();
                         if (fileName.indexOf('\\') > -1 || fileName.indexOf('/') > -1) {