Skip to content

Commit c2f6a98

Browse files
committed
Lenient handling of empty Content-Disposition filename
Closes gh-25769
1 parent 49d65d5 commit c2f6a98

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-web/src/main/java/org/springframework/http/HttpHeaders.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ public List<String> getConnection() {
861861
public void setContentDispositionFormData(String name, @Nullable String filename) {
862862
Assert.notNull(name, "Name must not be null");
863863
ContentDisposition.Builder disposition = ContentDisposition.builder("form-data").name(name);
864-
if (filename != null) {
864+
if (StringUtils.hasText(filename)) {
865865
disposition.filename(filename);
866866
}
867867
setContentDisposition(disposition.build());
@@ -888,7 +888,7 @@ public void setContentDisposition(ContentDisposition contentDisposition) {
888888
*/
889889
public ContentDisposition getContentDisposition() {
890890
String contentDisposition = getFirst(CONTENT_DISPOSITION);
891-
if (contentDisposition != null) {
891+
if (StringUtils.hasText(contentDisposition)) {
892892
return ContentDisposition.parse(contentDisposition);
893893
}
894894
return ContentDisposition.empty();

0 commit comments

Comments
 (0)