Skip to content

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

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

Closed
spring-projects-issues opened this issue Nov 6, 2015 · 1 comment
Assignees
Labels
type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues 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:

Referenced from: commits a1bf941

@spring-projects-issues
Copy link
Collaborator Author

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
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants