fix: 直接header设置Content-Type,彻底避免charset注入
This commit is contained in:
parent
66c21ae449
commit
d7d585ed42
@ -78,8 +78,9 @@ public class FileController {
|
||||
// 去掉可能的 charset 参数,避免 video Content-Type 被设为 "video/mp4;charset=UTF-8"
|
||||
int semi = contentType.indexOf(';');
|
||||
if (semi >= 0) contentType = contentType.substring(0, semi).trim();
|
||||
// 直接用 header 设置 Content-Type,绕过 Spring 的 Accept-Charset 逻辑
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.parseMediaType(contentType))
|
||||
.header("Content-Type", contentType)
|
||||
.body(new FileSystemResource(file));
|
||||
}
|
||||
|
||||
@ -97,8 +98,9 @@ public class FileController {
|
||||
// 去掉可能的 charset 参数,避免 video Content-Type 被设为 "video/mp4;charset=UTF-8"
|
||||
int semi = contentType.indexOf(';');
|
||||
if (semi >= 0) contentType = contentType.substring(0, semi).trim();
|
||||
// 直接用 header 设置 Content-Type,绕过 Spring 的 Accept-Charset 逻辑
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.parseMediaType(contentType))
|
||||
.header("Content-Type", contentType)
|
||||
.body(new FileSystemResource(file));
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user