mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 03:16:48 +08:00
HTTP响应截断
This commit is contained in:
@@ -436,6 +436,11 @@ public class CourseFileApi extends ApiBaseController {
|
||||
response.reset();
|
||||
//由于火狐和其他浏览器显示名称的方式不相同,需要进行不同的编码处理
|
||||
if (agent.indexOf("FIREFOX") != -1) {//火狐浏览器
|
||||
// 检查文件名中是否包含不允许的字符
|
||||
if (fileName.matches(".*[\n\r;%].*")) {
|
||||
throw new IllegalArgumentException("Filename contains illegal characters");
|
||||
}
|
||||
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("GB2312"), "ISO-8859-1"));
|
||||
} else {//其他浏览器
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
||||
|
||||
Reference in New Issue
Block a user