Re: [7.0.0-M1] Actions not setting parameters with Multi-part forms

"Burton Rhodes" <[email protected]>
Newsgroups gmane.comp.jakarta.struts.devel
Message-ID <[email protected]>
A bit more testing reveals a few clues/issues:
If I switch the parser to "jakarta" (instead of "jakarta-stream") 
everything works as expected.
The jakarta-stream parser is obviously not converting the stream for 
each action field variable to a String properly
When debugging the ParametersInterceptor (and using jakarta-stream), all 
the fields names exist in the parameters map, and their values are of 
type String, but the String value is: 
"org.apache.commons.fileupload2.core.MultipartInput$ItemInputStream@47453950"

When using the jakarta parser, I am finding that the 
"struts.multipart.maxFiles" setting is compared against the number of 
form fields in the request, not the number of files in the request.
For example, if I have a form with 10 text fields and 1 file field and 
maxFiles=10, I will get a "Request exceeded allowed number of files" 
error.
FYI: The maxFiles check is only made if a file exists in the request. If 
no file exists, then the multi-part form is successfully submitted 
regardless of the number of form fields

I am noticing an inconsistency in the way each parser stores the 
uploaded files in the temp dir. The jakarta parser stores the files with 
a "[uuid].tmp" extension and the "jakarta-stream" stores the uploaded 
file with the original file extension (e.g. [uuid].pdf).
I feel like they should be the same especially if you want to swap out 
parsers at a later time.  FWIW, the *.tmp extension breaks functionality 
in my application (although it's fairly trivial to fix on my end) so my 
vote would be to keep the original file extension - but perhaps this is 
a security issue?
Thanks,
Burton

------ Original Message ------
From "Burton Rhodes" <[email protected]>
To "Struts Developers List" <[email protected]>
Date 1/22/2024 9:12:57 PM
Subject [7.0.0-M1] Actions not setting parameters with Multi-part forms

>The biggest issue I'm having at the moment is with all of my multi-part forms that include parameter data and a file. The action does receive the file, but the parameter "team.company" is set to the String value of stream, for example:
>"org.apache.commons.fileupload2.core.MultipartInput$ItemInputStream@1afaa502"  Am I missing something obvious?
>
>To add, it actually doesn't matter if I have a file field in the form.  Any form with [enctype="multipart/form-data"] never sets the action fields properly.  Is there a different parser I should be referencing?  Or are my interceptors not correct?
>
>
>Example Form
><s:form name="frmTeamInfo" action="AdminTeam_update"
>         method="post" enctype="multipart/form-data" accept-charset="utf-8">
>     <s:textfield name="team.company" />
>     <s:file id="logoFileUpload" name="upload"/>
>     <s:submit value="Save" />
></s:form>
>
>Parser
><constant name="struts.multipart.parser" value="jakarta-stream" />
>
>Interceptor Stack
><interceptor-stack name="myParamsPrepareParamsStack">
>     <interceptor-ref name="exception"/>
>     <interceptor-ref name="checkbox"/>
>     <interceptor-ref name="datetime"/>
>     <interceptor-ref name="multiselect"/>
>     <interceptor-ref name="params"/>
>     <interceptor-ref name="servletConfig"/>
>     <interceptor-ref name="httpMethod"/>
>     <interceptor-ref name="prepare"/>
>     <interceptor-ref name="modelDriven"/>
>     <interceptor-ref name="fileUpload"/>
>     <interceptor-ref name="actionFileUpload"/>
>     <interceptor-ref name="staticParams"/>
>     <interceptor-ref name="actionMappingParams"/>
>     <interceptor-ref name="params"/>
>     <interceptor-ref name="conversionError"/>
>     <interceptor-ref name="validation">
>         <param name="excludeMethods">input,back,cancel,browse</param>
>     </interceptor-ref>
>     <interceptor-ref name="workflow">
>         <param name="excludeMethods">input,back,cancel,browse</param>
>     </interceptor-ref>
>     <interceptor-ref name="debugging"/>
></interceptor-stack>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.