mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 05:16:35 +08:00
fix lack of escaping of filename in Content-Disposition
This commit is contained in:
parent
a889c58de7
commit
ded02a8857
@ -1056,7 +1056,7 @@ func (c *Context) FileFromFS(filepath string, fs http.FileSystem) {
|
|||||||
// On the client side, the file will typically be downloaded with the given filename
|
// On the client side, the file will typically be downloaded with the given filename
|
||||||
func (c *Context) FileAttachment(filepath, filename string) {
|
func (c *Context) FileAttachment(filepath, filename string) {
|
||||||
if isASCII(filename) {
|
if isASCII(filename) {
|
||||||
c.Writer.Header().Set("Content-Disposition", `attachment; filename="`+filename+`"`)
|
c.Writer.Header().Set("Content-Disposition", `attachment; filename="`+strings.Replace(filename, "\"", "\\\"", -1)+`"`)
|
||||||
} else {
|
} else {
|
||||||
c.Writer.Header().Set("Content-Disposition", `attachment; filename*=UTF-8''`+url.QueryEscape(filename))
|
c.Writer.Header().Set("Content-Disposition", `attachment; filename*=UTF-8''`+url.QueryEscape(filename))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user