ServletUtil遵循rfc 3986优化

This commit is contained in:
Looly 2023-01-16 10:17:51 +08:00
parent b212fdc685
commit 21eecdc760
3 changed files with 8 additions and 5 deletions

View File

@ -3,13 +3,14 @@
-------------------------------------------------------------------------------------------------------------
# 5.8.12.M1 (2023-01-15)
# 5.8.12.M1 (2023-01-16)
### 🐣新特性
* 【core 】 XmlUtil.readObjectFromXml增加注入漏洞的警告注释并标识为废弃issue#2857@Github
* 【http 】 HttpGlobalConfig.allowPatch()调用时忽略错误issue#2832@Github
* 【core 】 重构根据file magic number判断文件类型pr#2834@Github
* 【core 】 增加WGS84 坐标与墨卡托投影互转pr#2811@Github
* 【extra 】 ServletUtil遵循rfc 3986优化issue#I6ALAO@Gitee
### 🐞Bug修复
* 【core 】 修复HexUtil.isHexNumber()对"-"的判断问题issue#2857@Github

View File

@ -614,8 +614,9 @@ public class JakartaServletUtil {
*/
public static void write(HttpServletResponse response, InputStream in, String contentType, String fileName) {
final String charset = ObjectUtil.defaultIfNull(response.getCharacterEncoding(), CharsetUtil.UTF_8);
response.setHeader("Content-Disposition", StrUtil.format("attachment;filename=\"{}\"",
URLUtil.encode(fileName, CharsetUtil.charset(charset))));
final String encodeText = URLUtil.encodeAll(fileName, CharsetUtil.charset(charset));
response.setHeader("Content-Disposition",
StrUtil.format("attachment;filename=\"{}\";filename*={}''{}", encodeText, charset, encodeText));
response.setContentType(contentType);
write(response, in);
}

View File

@ -613,8 +613,9 @@ public class ServletUtil {
*/
public static void write(HttpServletResponse response, InputStream in, String contentType, String fileName) {
final String charset = ObjectUtil.defaultIfNull(response.getCharacterEncoding(), CharsetUtil.UTF_8);
response.setHeader("Content-Disposition", StrUtil.format("attachment;filename=\"{}\"",
URLUtil.encode(fileName, CharsetUtil.charset(charset))));
final String encodeText = URLUtil.encodeAll(fileName, CharsetUtil.charset(charset));
response.setHeader("Content-Disposition",
StrUtil.format("attachment;filename=\"{}\";filename*={}''{}", encodeText, charset, encodeText));
response.setContentType(contentType);
write(response, in);
}