Browse Source

escape file name when there is a quote inside

pull/2/head
Chris Lu 12 years ago
parent
commit
c35fe9d631
  1. 4
      weed-fs/src/cmd/weed/volume.go

4
weed-fs/src/cmd/weed/volume.go

@ -42,6 +42,8 @@ var (
store *storage.Store store *storage.Store
) )
var fileNameEscaper = strings.NewReplacer("\\","\\\\","\"","\\\"")
func statusHandler(w http.ResponseWriter, r *http.Request) { func statusHandler(w http.ResponseWriter, r *http.Request) {
m := make(map[string]interface{}) m := make(map[string]interface{})
m["Version"] = VERSION m["Version"] = VERSION
@ -147,7 +149,7 @@ func GetHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", mtype) w.Header().Set("Content-Type", mtype)
} }
if n.NameSize > 0 { if n.NameSize > 0 {
w.Header().Set("Content-Disposition", "filename="+string(n.Name))
w.Header().Set("Content-Disposition", "filename="+fileNameEscaper.Replace(string(n.Name)))
} }
if ext != ".gz" { if ext != ".gz" {
if n.IsGzipped() { if n.IsGzipped() {

Loading…
Cancel
Save