Commit 5ae1356e authored by Kamil Trzcinski's avatar Kamil Trzcinski

Use proper quotes escaping for DownloadArtifact method

Uses escaper from mime/multipart/writer.go.
parent e0a2ea65
......@@ -58,10 +58,12 @@ func unpackFileFromZip(archiveFileName, fileName string, headers http.Header, ou
}
defer reader.Close()
basename := filepath.Base(fileName)
// Write http headers about the file
headers.Set("Content-Length", strconv.FormatInt(int64(file.UncompressedSize64), 10))
headers.Set("Content-Type", detectFileContentType(file.Name))
headers.Set("Content-Disposition", "attachment; filename=\""+filepath.Base(file.Name)+"\"")
headers.Set("Content-Disposition", "attachment; filename=\""+escapeQuotes(basename)+"\"")
// Copy file body to client
_, err = io.Copy(output, reader)
......
package artifacts
import "strings"
// taken from mime/multipart/writer.go
var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"")
func escapeQuotes(s string) string {
return quoteEscaper.Replace(s)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment