Merge pull request #438 from sd65/fix-sql-export

Fix SQL export filename
This commit is contained in:
Dan Sosedoff 2019-07-31 20:45:17 -05:00 committed by GitHub
commit 1e4a09d8b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)