Browse Source

Lenient handling of empty Content-Disposition filename

Closes gh-25769
pull/25798/head
Juergen Hoeller 4 years ago
parent
commit
c2f6a98c90
  1. 4
      spring-web/src/main/java/org/springframework/http/HttpHeaders.java

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

@ -861,7 +861,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable @@ -861,7 +861,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, 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<String, String>, Serializable @@ -888,7 +888,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
*/
public ContentDisposition getContentDisposition() {
String contentDisposition = getFirst(CONTENT_DISPOSITION);
if (contentDisposition != null) {
if (StringUtils.hasText(contentDisposition)) {
return ContentDisposition.parse(contentDisposition);
}
return ContentDisposition.empty();

Loading…
Cancel
Save