From f563300c58e31cd24fb81e35e6c1be0cb251212e Mon Sep 17 00:00:00 2001 From: Harry Date: Sun, 20 Feb 2022 12:22:35 +0530 Subject: [PATCH] valid id --- pkg/parser/parser.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index cb5c7b3..c4f4cc9 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -9,6 +9,8 @@ import ( "strings" ) +var idRegex = regexp.MustCompile(`^@[a-zA-Z][a-z-A-Z0-9-_]+$`) + type File struct { Global Global Requests []Request @@ -50,6 +52,9 @@ func Parse(filename string) (File, error) { return File{}, err } case strings.HasPrefix(line, "@"): + if !idRegex.MatchString(line) { + return File{}, fmt.Errorf("invalid id: '%v'", line) + } id := line[1:] req, err := request(id, sc) if err != nil {