From c35fe9d6318ed9b38e7d05c9e1c0de5e2f06f54c Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 2 Jan 2013 13:40:00 -0800 Subject: [PATCH] escape file name when there is a quote inside --- weed-fs/src/cmd/weed/volume.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/weed-fs/src/cmd/weed/volume.go b/weed-fs/src/cmd/weed/volume.go index 4d3737dbd..59a5623ea 100644 --- a/weed-fs/src/cmd/weed/volume.go +++ b/weed-fs/src/cmd/weed/volume.go @@ -42,6 +42,8 @@ var ( store *storage.Store ) +var fileNameEscaper = strings.NewReplacer("\\","\\\\","\"","\\\"") + func statusHandler(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) m["Version"] = VERSION @@ -147,7 +149,7 @@ func GetHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", mtype) } 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 n.IsGzipped() {