Only write non-default charset in FormHttpMessageConverter

This commit only writes the 'charset' parameter in the written headers
if it is non-default (not UTF-8), since RFC7578 states that the only
allowed parameter is 'boundary'.

See gh-25885
Closes gh-26290
This commit is contained in:
Arjen Poutsma
2021-01-08 14:03:58 +01:00
parent 69ce7d33b9
commit ce1ae2f1b2
2 changed files with 27 additions and 1 deletions

View File

@@ -475,7 +475,10 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
byte[] boundary = generateMultipartBoundary();
if (!isFilenameCharsetSet()) {
parameters.put("charset", this.charset.name());
if (!this.charset.equals(StandardCharsets.UTF_8) &&
!this.charset.equals(StandardCharsets.US_ASCII)) {
parameters.put("charset", this.charset.name());
}
}
parameters.put("boundary", new String(boundary, StandardCharsets.US_ASCII));