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

HttpHeaders.setContentDispositionFormData should ignore empty filename #25769

Closed
npimentel opened this issue Sep 14, 2020 · 0 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@npimentel
Copy link

npimentel commented Sep 14, 2020

When a Multipart Form request is used with an empty string as Filename, a "No Filename" exception is thrown. Can an empty String check be added to prevent the code from failing in empty string scenarios?

public void setContentDispositionFormData(String name, @Nullable String filename) {
		Assert.notNull(name, "Name must not be null");
		ContentDisposition.Builder disposition = ContentDisposition.builder("form-data").name(name);
		 if (filename != null) {  // Add Empty String check here, don't let through if empty String
			disposition.filename(filename);    // calls method below
		}
		setContentDisposition(disposition.build());
	}

@Override
		public Builder filename(String filename) {
			Assert.hasText(filename, "No filename");  // Assertion Fails since the the filename does not have text
			this.filename = filename;
			return this;
		}

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 14, 2020
@jhoeller jhoeller changed the title Filename Not Found Exception when submitting Multipart Forms with empty filename HttpHeaders.setContentDispositionFormData should ignore empty filename Sep 14, 2020
@jhoeller jhoeller self-assigned this Sep 14, 2020
@jhoeller jhoeller added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 14, 2020
@jhoeller jhoeller added this to the 5.2.9 milestone Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants