diff --git a/main.go b/main.go index a643cde8..a591d88f 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "path/filepath" + "regexp" "sort" "strconv" "strings" @@ -71,6 +72,11 @@ func (l *ParsedList) toProto() (*router.GeoSite, error) { Attribute: entry.Attrs, }) case "regexp": + // check regexp validity to avoid runtime error + _, err := regexp.Compile(entry.Value) + if err != nil { + return nil, fmt.Errorf("invalid regexp in list %s: %s", l.Name, entry.Value) + } site.Domain = append(site.Domain, &router.Domain{ Type: router.Domain_Regex, Value: entry.Value,