Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

escape file name only when necessary

Chris Lu34f764007fb5
diff --git a/weed/server/common.go b/weed/server/common.go
index 634d5757cc..f7a7619f3c 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 9fc9da60f3..c24e8780c0 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())