Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

serve http: escape filename in zip download Content-Disposition header

Harsh Raj Singhania661484f36c40
diff --git a/cmd/serve/http/http.go b/cmd/serve/http/http.go
index 9ec487c2a..c22b40d33 100644
--- a/cmd/serve/http/http.go
+++ b/cmd/serve/http/http.go
@@ -6,6 +6,7 @@ import (
_ "embed"
"fmt"
"io"
+ "mime"
"net"
"net/http"
"os"
@@ -295,7 +296,7 @@ func (s *HTTP) serveDir(w http.ResponseWriter, r *http.Request, dirRemote string
if dirRemote == "" {
zipName = "root"
}
- w.Header().Set("Content-Disposition", "attachment; filename=\""+zipName+".zip\"")
+ w.Header().Set("Content-Disposition", mime.FormatMediaType("attachment", map[string]string{"filename": zipName + ".zip"}))
w.Header().Set("Content-Type", "application/zip")
w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
err := vfs.CreateZip(ctx, dir, w)