fix regex

(cherry picked from commit a259213a3badc9618e969f2c8db0a0143f00faee)
This commit is contained in:
Will Browne
2021-12-10 10:56:38 +01:00
committed by Marcus Efraimsson
parent 06706efbbe
commit 1d7105c095
+4 -1
View File
@@ -8,6 +8,7 @@ import (
"io"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
@@ -72,7 +73,9 @@ func (s *Service) handleCsvFileScenario(ctx context.Context, req *backend.QueryD
}
func (s *Service) loadCsvFile(fileName string) (*data.Frame, error) {
if filepath.Ext(fileName) != ".csv" || strings.Contains(fileName, "..") {
validFileName := regexp.MustCompile(`^\w+\.csv$`)
if !validFileName.MatchString(fileName) {
return nil, fmt.Errorf("invalid csv file name: %q", fileName)
}