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" "errors"
"fmt" "fmt"
neturl "net/url" neturl "net/url"
"regexp"
"strings" "strings"
"time" "time"
@@ -481,10 +482,12 @@ func DataExport(c *gin.Context) {
if dump.Table != "" { if dump.Table != "" {
filename = filename + "_" + dump.Table filename = filename + "_" + dump.Table
} }
reg := regexp.MustCompile("[^._\\w]+")
cleanFilename := reg.ReplaceAllString(filename, "")
c.Header( c.Header(
"Content-Disposition", "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) err = dump.Export(db.ConnectionString, c.Writer)