[
https://issues.apache.org/jira/browse/WW-5088?focusedWorklogId=480404&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-480404
]
ASF GitHub Bot logged work on WW-5088:
--------------------------------------
Author: ASF GitHub Bot
Created on: 08/Sep/20 19:51
Start Date: 08/Sep/20 19:51
Worklog Time Spent: 10m
Work Description: JCgH4164838Gh792C124B5 commented on pull request #435:
URL: https://github.com/apache/struts/pull/435#issuecomment-689100828
Hi.
Although it seems unlikely, there might be someone with a current use case
for uploading empty files. For this PR's change, maybe there should be a
different error message string lookup for the new check added with this PR
(e.g. "struts.messages.error.file.empty") to make it clear why the upload is
being rejected ?
Another idea might be to introduce a "minimumSize" property for the file
upload that developers can configure (with a default of 0 or 1, depending on
whether accepting empty files should be allowed by default). That sort of
feature could replace an empty guard with something configurable.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 480404)
Time Spent: 20m (was: 10m)
> Empty file upload gives wrong error message
> -------------------------------------------
>
> Key: WW-5088
> URL: https://issues.apache.org/jira/browse/WW-5088
> Project: Struts 2
> Issue Type: Bug
> Components: Core Interceptors
> Affects Versions: 2.5.22
> Reporter: Greg Huber
> Priority: Minor
> Fix For: 2.6
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> On an empty file upload the storeLocation is null, so adds a file new
> StrutsUploadedFile(null)
> JakartaMultiPartRequest
> {code:java}
> List fileList = new ArrayList<>(items.size());
> for (FileItem fileItem : items) {
> File storeLocation = ((DiskFileItem) fileItem).getStoreLocation();
> if (fileItem.isInMemory() && storeLocation != null &&
> !storeLocation.exists()) {
> try {
> storeLocation.createNewFile();
> } catch (IOException e) {
> LOG.error("Cannot write uploaded empty file to disk: {}",
> storeLocation.getAbsolutePath(), e);
> }
> }
> fileList.add(new StrutsUploadedFile(storeLocation));
> }
> {code}
> The FileUploadInterceptor checks for a null file but not null content from
> the new StrutsUploadedFile(null).
> eg for an empty file main.js
> Error message should be:
> Error uploading: main.js
> but gives:
> Error setting expression 'uploadedFiles' with value
> ['org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@202585bc', ]
> Error setting expression 'uploadedFiles' with value
> ['org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@49553150', ]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)