Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonsMultipartResolver.setMaxUploadSizePerFile() does not work if encoding does not match the default encoding [SPR-13653] #18229

Closed
spring-issuemaster opened this issue Nov 6, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Nov 6, 2015

Alex Shesterov opened SPR-13653 and commented

Release 4.2 added support for per-file size limits — task #17792.
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;
	}

Affects: 4.2.2

Issue Links:

  • #17792 CommonsMultipartResolver should support setFileSizeMax
  • #19204 CommonsMultipartResolver should explicitly convert FileSizeLimitExceededException next to SizeLimitExceededException

Referenced from: commits a1bf941

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 7, 2015

Juergen Hoeller commented

Good catch! Fixed in master now - to be released in 4.2.3.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.