fix SQL export filename

This commit is contained in:
Sylvain DOIGNON 2019-07-31 14:39:31 +02:00
parent 1334e48fc7
commit 5bb339e1a2

View File

@ -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)