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());
}
|
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;
}
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
spring-framework/spring-web/src/main/java/org/springframework/http/ContentDisposition.java
Line 601 in 29885e2