mirror of
https://github.com/v2fly/domain-list-community.git
synced 2025-12-16 23:50:05 +07:00
Feat: check regexp before build (#3064)
Co-authored-by: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
This commit is contained in:
6
main.go
6
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,
|
||||
|
||||
Reference in New Issue
Block a user