Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-13653

CommonsMultipartResolver.setMaxUploadSizePerFile() does not work if encoding does not match the default encoding

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.2.2
    • Fix Version/s: 4.2.3
    • Component/s: [Build]
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      Release 4.2 added support for per-file size limits — task SPR-13200.
      The new method is CommonsFileUploadSupport.setMaxUploadSizePerFile(long).

      But this setting has no effect if file encoding does not match default encoding.

      The reason is the following code in CommonsFileUploadSupport:

      	protected FileUpload prepareFileUpload(String encoding) {
      		FileUpload fileUpload = getFileUpload();
      		FileUpload actualFileUpload = fileUpload;
      
      		// Use new temporary FileUpload instance if the request specifies
      		// its own encoding that does not match the default encoding.
      		if (encoding != null && !encoding.equals(fileUpload.getHeaderEncoding())) {
      			actualFileUpload = newFileUpload(getFileItemFactory());
      			actualFileUpload.setSizeMax(fileUpload.getSizeMax());
      
      			// !!missing:  actualFileUpload.setFileSizeMax(fileUpload.getFileSizeMax());
      
      			actualFileUpload.setHeaderEncoding(encoding);
      		}
      
      		return actualFileUpload;
      	}
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                juergen.hoeller Juergen Hoeller
                Reporter:
                alex.shesterov Alex Shesterov
                Last updater:
                Juergen Hoeller
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  2 years, 41 weeks, 2 days ago