Compare commits

...

1 Commits

Author SHA1 Message Date
风扇滑翔翼
93bfcfd142 Feat: check regexp before build (#3064)
Co-authored-by: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
2025-12-16 23:40:25 +08:00

View File

@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"regexp"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
@@ -71,6 +72,11 @@ func (l *ParsedList) toProto() (*router.GeoSite, error) {
Attribute: entry.Attrs, Attribute: entry.Attrs,
}) })
case "regexp": 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{ site.Domain = append(site.Domain, &router.Domain{
Type: router.Domain_Regex, Type: router.Domain_Regex,
Value: entry.Value, Value: entry.Value,