1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-23 11:03:48 +00:00

🐛 Escape fname

This commit is contained in:
Fenny 2020-07-10 22:25:10 +02:00
parent fc5d2d7e66
commit f698b5d506

2
ctx.go
View File

@ -196,7 +196,7 @@ func (ctx *Ctx) Attachment(filename ...string) {
if len(filename) > 0 { if len(filename) > 0 {
fname := filepath.Base(filename[0]) fname := filepath.Base(filename[0])
ctx.Type(filepath.Ext(fname)) ctx.Type(filepath.Ext(fname))
ctx.Set(HeaderContentDisposition, `attachment; filename="`+fname+`"`) ctx.Set(HeaderContentDisposition, `attachment; filename="`+url.QueryEscape(fname)+`"`)
return return
} }
ctx.Set(HeaderContentDisposition, "attachment") ctx.Set(HeaderContentDisposition, "attachment")