From 5bb339e1a2bec45ad855d3862e1d50ba809d1b3e Mon Sep 17 00:00:00 2001 From: Sylvain DOIGNON Date: Wed, 31 Jul 2019 14:39:31 +0200 Subject: [PATCH] fix SQL export filename --- pkg/api/api.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index 56a13e3..08d5854 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" neturl "net/url" + "regexp" "strings" "time" @@ -481,10 +482,12 @@ func DataExport(c *gin.Context) { if dump.Table != "" { filename = filename + "_" + dump.Table } + reg := regexp.MustCompile("[^._\\w]+") + cleanFilename := reg.ReplaceAllString(filename, "") c.Header( "Content-Disposition", - fmt.Sprintf(`attachment; filename="%s.sql.gz"`, filename), + fmt.Sprintf(`attachment; filename="%s.sql.gz"`, cleanFilename), ) err = dump.Export(db.ConnectionString, c.Writer)