[MAGNOLIA-8902] MultipartRequestFilter sets filesCountMax to 10 by default and only 9 fields are enabled to be sent Created: 18/May/23  Updated: 01/Jun/23  Resolved: 23/May/23

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 6.2.34
Fix Version/s: None

Type: Bug Priority: High
Reporter: Francisco J. Giner Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
duplicate
is duplicated by MAGNOLIA-8889 MultipartRequestFilter#fileCountMax r... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Steps to reproduce

  1. Upload Magnolia to 6.2.30 or more recent
  2. Create a template with a form that contains 10 fields or more where some fields are file inputs.
  3. Change form enctype to multipart/form-data

Expected results

Form is sent correctly and you can use the information of the request to do some logic.

Actual results

MultipartRequestFilter throws an exception because it can't handle 10 or more fields, but this should only be for "file" type fields and it is counting also text, checkbox, select, etc... fields.

Workaround

Increase to a big number the value of the property "fileCountMax" for MultipartRequestFilter filter at the configuration in /server/filters/multipartRequest/. For example: 

fileCountMax: 100

Development notes

Since in Magnolia 6.2.30 changed to commons-fileupload 1.5.0, this library "allows" to set a max of files you can upload in a request, but this library is not checking only files in the request. Is checking ALL the fields (files or not) in the request.

You can check it in this commit from the github library: https://github.com/apache/commons-fileupload/commit/e20c04990f7420ca917e96a84cec58b13a1b3d17#commitcomment-113912200



 Comments   
Comment by Francisco J. Giner [ 18/May/23 ]

Exception throwed: 

ERROR info.magnolia.cms.filters.MultipartRequestFilter  : Could not upload files:attachment

org.apache.commons.fileupload.FileCountLimitExceededException: attachment

    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:367) ~[commons-fileupload-1.5.jar:1.5] 
Comment by Francisco J. Giner [ 18/May/23 ]

Sorry, title is in Spanish.
In English: MultipartRequestFilter sets filesCountMax to 10 by default and only 9 fields are enabled to be sent

Comment by Francisco J. Giner [ 22/May/23 ]

Confirmed by the developer who made this change in the "commons-fileupload" library:

https://github.com/apache/commons-fileupload/commit/e20c04990f7420ca917e96a84cec58b13a1b3d17#commitcomment-114412631

In the Magnolia code you have defined this variable with a value of 10 by default, thinking that it only affected files, but no, it affects the total number of fields that are sent in the form. So, every form that have 10 or more fields, fails.

Comment by Richard Gange [ 23/May/23 ]

This issue duplicates MAGNOLIA-8889

Generated at Mon Feb 12 04:36:49 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.