From c2f6a98c907c01596f3a082dd0bc3dcf65fcb927 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 14 Sep 2020 22:16:12 +0200 Subject: [PATCH] Lenient handling of empty Content-Disposition filename Closes gh-25769 --- .../src/main/java/org/springframework/http/HttpHeaders.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index aaa65b5e44..37c8445b9b 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -861,7 +861,7 @@ public class HttpHeaders implements MultiValueMap, Serializable 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) { + if (StringUtils.hasText(filename)) { disposition.filename(filename); } setContentDisposition(disposition.build()); @@ -888,7 +888,7 @@ public class HttpHeaders implements MultiValueMap, Serializable */ public ContentDisposition getContentDisposition() { String contentDisposition = getFirst(CONTENT_DISPOSITION); - if (contentDisposition != null) { + if (StringUtils.hasText(contentDisposition)) { return ContentDisposition.parse(contentDisposition); } return ContentDisposition.empty();