#4848 浏览原始文件时pdf文件强制浏览器下载而不是打开,防止pdf嵌入脚本执行

Merged
zouap merged 2 commits from fix-2990 into V20231102 6 months ago
  1. +1
    -1
      routers/repo/download.go

+ 1
- 1
routers/repo/download.go View File

@@ -43,7 +43,7 @@ func ServeData(ctx *context.Context, name string, reader io.Reader) error {
cs = "utf-8"
}
ctx.Resp.Header().Set("Content-Type", "text/plain; charset="+strings.ToLower(cs))
} else if base.IsImageFile(buf) || base.IsPDFFile(buf) {
} else if base.IsImageFile(buf) {
ctx.Resp.Header().Set("Content-Disposition", fmt.Sprintf(`inline; filename="%s"`, name))
} else {
ctx.Resp.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, name))


Loading…
Cancel
Save