Browse Source

escape file name only when necessary

pull/2376/head
Chris Lu 3 years ago
parent
commit
34f764007f
  1. 2
      weed/server/common.go
  2. 2
      weed/server/filer_server_handlers_read.go

2
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 {

2
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())

Loading…
Cancel
Save