escape file name only when necessary
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -256,6 +257,7 @@ func adjustHeaderContentDisposition(w http.ResponseWriter, r *http.Request, file
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if filename != "" {
|
if filename != "" {
|
||||||
|
filename = url.QueryEscape(filename)
|
||||||
contentDisposition := "inline"
|
contentDisposition := "inline"
|
||||||
if r.FormValue("dl") != "" {
|
if r.FormValue("dl") != "" {
|
||||||
if dl, _ := strconv.ParseBool(r.FormValue("dl")); dl {
|
if dl, _ := strconv.ParseBool(r.FormValue("dl")); dl {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -133,7 +132,6 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
setEtag(w, etag)
|
setEtag(w, etag)
|
||||||
|
|
||||||
filename := entry.Name()
|
filename := entry.Name()
|
||||||
filename = url.QueryEscape(filename)
|
|
||||||
adjustHeaderContentDisposition(w, r, filename)
|
adjustHeaderContentDisposition(w, r, filename)
|
||||||
|
|
||||||
totalSize := int64(entry.Size())
|
totalSize := int64(entry.Size())
|
||||||
|
|||||||
Reference in New Issue
Block a user