mirror of
https://github.com/v2fly/domain-list-community.git
synced 2025-12-17 16:10:04 +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"
|
"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,
|
||||||
|
|||||||
Reference in New Issue
Block a user