From 34f764007fb5de0adb9b666cf42cab2aeea2ef00 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 11 Oct 2021 23:33:45 -0700 Subject: [PATCH] escape file name only when necessary --- weed/server/common.go | 2 ++ weed/server/filer_server_handlers_read.go | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/weed/server/common.go b/weed/server/common.go index 634d5757c..f7a7619f3 100644 --- a/weed/server/common.go +++ b/weed/server/common.go @@ -9,6 +9,7 @@ import ( "io/fs" "mime/multipart" "net/http" + "net/url" "path/filepath" "strconv" "strings" @@ -256,6 +257,7 @@ func adjustHeaderContentDisposition(w http.ResponseWriter, r *http.Request, file return } if filename != "" { + filename = url.QueryEscape(filename) contentDisposition := "inline" if r.FormValue("dl") != "" { if dl, _ := strconv.ParseBool(r.FormValue("dl")); dl { diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go index 9fc9da60f..c24e8780c 100644 --- a/weed/server/filer_server_handlers_read.go +++ b/weed/server/filer_server_handlers_read.go @@ -7,7 +7,6 @@ import ( "io" "mime" "net/http" - "net/url" "path/filepath" "strconv" "strings" @@ -133,7 +132,6 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request) setEtag(w, etag) filename := entry.Name() - filename = url.QueryEscape(filename) adjustHeaderContentDisposition(w, r, filename) totalSize := int64(entry.Size())