-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Wenhao Ji opened SPR-14547 and commented
When passing name or filename containing non-ascii characters to the setContentDispositionFormData
method, a browser like Chrome and IE may behave strangely, opening a download dialog where those characters are replaced by hyphens.
The parameters in http headers should be encoded according to [RFC5987] https://tools.ietf.org/html/rfc5987, so that we can get the correct string no matter what kind of characters are passed into.
For example,
@RequestMapping("downloadForm")
public HttpEntity<String> downloadFormData() throws UnsupportedEncodingException {
HttpHeaders headers = new HttpHeaders();
headers.setContentDispositionFormData("form", "中文.txt");
return new HttpEntity<String>("a=b", headers);
}
The Content-Disposition
header values that returns from the controller method above should be like filename=UTF-8'zh-Hant-CN'%E4%B8%AD%E6%96%87.txt
.
Affects: 4.3.2
Issue Links:
- Switch source encoding to UTF-8 and enforce it in the build [SPR-11569] #16193 Switch source encoding to UTF-8 and enforce it in the build
- FormHttpMessageConverter doesn't support utf-8 filename [SPR-16061] #20610 FormHttpMessageConverter doesn't support utf-8 filename
- Allow configuring the message converter in HttpPutFormContentFilter [SPR-14503] #19072 Allow configuring the message converter in HttpPutFormContentFilter
- StandardMultipartHttpServletRequest cannot decode multipart Content-Disposition header encoded by FormHttpMessageConverter [SPR-15205] #19769 StandardMultipartHttpServletRequest cannot decode multipart Content-Disposition header encoded by FormHttpMessageConverter
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement