fix(files): encode download filenames

This commit is contained in:
rissrice2105-agent 2026-07-12 15:22:52 -06:00
parent 21630c2d17
commit 2154dd9c50
2 changed files with 42 additions and 1 deletions

View file

@ -7,6 +7,7 @@ import (
"fmt"
"html/template"
"io"
"mime"
"net/http"
"os"
"path"
@ -224,7 +225,9 @@ func (h *webSrv) handleDownload(w http.ResponseWriter, r *http.Request) {
return
}
defer f.Close()
w.Header().Set("Content-Disposition", "attachment; filename=\""+path.Base(vpath)+"\"")
w.Header().Set("Content-Disposition", mime.FormatMediaType("attachment", map[string]string{
"filename": path.Base(vpath),
}))
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Length", strconv.FormatInt(fi.Size(), 10))
_, _ = io.Copy(w, f)