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 webdav: escape filename in zip download Content-Disposition header

Harsh Raj Singhania14a1359c96b5
diff --git a/cmd/serve/webdav/webdav.go b/cmd/serve/webdav/webdav.go
index f3cf2aa82..d36be62a3 100644
--- a/cmd/serve/webdav/webdav.go
+++ b/cmd/serve/webdav/webdav.go
@@ -451,7 +451,7 @@ func (w *WebDAV) serveDir(rw http.ResponseWriter, r *http.Request, dirRemote str
if dirRemote == "" {
zipName = "root"
}
- rw.Header().Set("Content-Disposition", "attachment; filename=\""+zipName+".zip\"")
+ rw.Header().Set("Content-Disposition", mime.FormatMediaType("attachment", map[string]string{"filename": zipName + ".zip"}))
rw.Header().Set("Content-Type", "application/zip")
rw.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
err := vfs.CreateZip(ctx, dir, rw)