From 5d906172754dfda9f80f0552a2f42614c7c5ad36 Mon Sep 17 00:00:00 2001 From: Paul Warren Date: Wed, 23 Aug 2023 20:59:24 -0700 Subject: [PATCH] fix: now uses utf8 when setting content-dispostion filename (#1583) windows defaults to windows-1252 which is not compliant with rfc5987 that governs how to encode header fields Fixes #1556 --- .../content/rest/io/AssociatedStoreResourceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-content-rest/src/main/java/internal/org/springframework/content/rest/io/AssociatedStoreResourceImpl.java b/spring-content-rest/src/main/java/internal/org/springframework/content/rest/io/AssociatedStoreResourceImpl.java index 1c0b77fce..5a042bbc7 100644 --- a/spring-content-rest/src/main/java/internal/org/springframework/content/rest/io/AssociatedStoreResourceImpl.java +++ b/spring-content-rest/src/main/java/internal/org/springframework/content/rest/io/AssociatedStoreResourceImpl.java @@ -11,6 +11,7 @@ import java.nio.channels.ReadableByteChannel; import java.nio.channels.WritableByteChannel; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.time.Instant; import java.util.Date; import java.util.stream.Stream; @@ -193,7 +194,7 @@ public HttpHeaders getResponseHeaders() { // Modified to show download Object originalFileName = this.getContentProperty().getOriginalFileName(this.getAssociation()); if (originalFileName != null && StringUtils.hasText(originalFileName.toString())) { - headers.setContentDisposition(ContentDisposition.attachment().filename((String) originalFileName, Charset.defaultCharset()).build()); + headers.setContentDisposition(ContentDisposition.attachment().filename((String) originalFileName, StandardCharsets.UTF_8).build()); } else { headers.setContentDisposition(ContentDisposition.attachment().build()); }