Skip to content

Commit

Permalink
Merge branch '5.8.x' into 6.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusdacoregio committed Sep 25, 2023
2 parents f06c2b9 + 664ee9a commit 1a0b8b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void writeMetadataToResponse(HttpServletResponse response, String regist
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.name());
String format = "attachment; filename=\"%s\"; filename*=UTF-8''%s";
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format(format, fileName, encodedFileName));
response.setContentLength(metadata.length());
response.setContentLength(metadata.getBytes(StandardCharsets.UTF_8).length);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
response.getWriter().write(metadata);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ public void doFilterWhenCharacterEncodingThenEncodeSpecialCharactersCorrectly()
this.filter.doFilter(this.request, this.response, this.chain);
assertThat(this.response.getCharacterEncoding()).isEqualTo(StandardCharsets.UTF_8.name());
assertThat(this.response.getContentAsString(StandardCharsets.UTF_8)).isEqualTo(generatedMetadata);
assertThat(this.response.getContentLength())
.isEqualTo(generatedMetadata.getBytes(StandardCharsets.UTF_8).length);
}

@Test
Expand Down

0 comments on commit 1a0b8b7

Please sign in to comment.