aboutsummaryrefslogtreecommitdiffstats
path: root/routers/common/repo.go
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2022-05-28 18:10:14 +0300
committerGitHub <noreply@github.com>2022-05-28 18:10:14 +0300
commit65e0688a5c9dacad50e71024b7529fdf0e3c2e9c (patch)
treeab10b986df4dd03bd2d1a8230e4b6f8559966e99 /routers/common/repo.go
parent410df1fbd47aa17488f7167d868c85e84c8217ef (diff)
downloadgitea-65e0688a5c9dacad50e71024b7529fdf0e3c2e9c.tar.gz
gitea-65e0688a5c9dacad50e71024b7529fdf0e3c2e9c.zip
Fix raw endpoint PDF file headers (#19825)
Diffstat (limited to 'routers/common/repo.go')
-rw-r--r--routers/common/repo.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/routers/common/repo.go b/routers/common/repo.go
index d037e151f9..b3cd749115 100644
--- a/routers/common/repo.go
+++ b/routers/common/repo.go
@@ -88,10 +88,14 @@ func ServeData(ctx *context.Context, name string, size int64, reader io.Reader)
}
if (st.IsImage() || st.IsPDF()) && (setting.UI.SVG.Enabled || !st.IsSvgImage()) {
ctx.Resp.Header().Set("Content-Disposition", fmt.Sprintf(`inline; filename="%s"`, name))
- if st.IsSvgImage() {
+ if st.IsSvgImage() || st.IsPDF() {
ctx.Resp.Header().Set("Content-Security-Policy", "default-src 'none'; style-src 'unsafe-inline'; sandbox")
ctx.Resp.Header().Set("X-Content-Type-Options", "nosniff")
- ctx.Resp.Header().Set("Content-Type", typesniffer.SvgMimeType)
+ if st.IsSvgImage() {
+ ctx.Resp.Header().Set("Content-Type", typesniffer.SvgMimeType)
+ } else {
+ ctx.Resp.Header().Set("Content-Type", typesniffer.ApplicationOctetStream)
+ }
}
} else {
ctx.Resp.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, name))