-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
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?
spring-framework/spring-web/src/main/java/org/springframework/http/HttpHeaders.java
Line 864 in 3b0f14f
| if (filename != null) { |
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());
}
spring-framework/spring-web/src/main/java/org/springframework/http/ContentDisposition.java
Line 601 in 29885e2
| Assert.hasText(filename, "No filename"); |
@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;
}
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement