mirror of
https://github.com/safing/portmaster
synced 2025-09-04 19:49:15 +00:00
Ignore comments on rule parsing
This commit is contained in:
parent
cb9d8cee06
commit
295efbb3a2
2 changed files with 11 additions and 1 deletions
|
@ -208,6 +208,14 @@ func parseEndpoint(value string) (endpoint Endpoint, err error) { //nolint:gocog
|
||||||
return nil, fmt.Errorf(`invalid endpoint definition: "%s"`, value)
|
return nil, fmt.Errorf(`invalid endpoint definition: "%s"`, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove comment.
|
||||||
|
for i, field := range fields {
|
||||||
|
if strings.HasPrefix(field, "#") {
|
||||||
|
fields = fields[:i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// any
|
// any
|
||||||
if endpoint, err = parseTypeAny(fields); endpoint != nil || err != nil {
|
if endpoint, err = parseTypeAny(fields); endpoint != nil || err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -62,11 +62,13 @@ entriesLoop:
|
||||||
// ListEntryValidationRegex is a regex to bullshit check endpoint list entries.
|
// ListEntryValidationRegex is a regex to bullshit check endpoint list entries.
|
||||||
var ListEntryValidationRegex = strings.Join([]string{
|
var ListEntryValidationRegex = strings.Join([]string{
|
||||||
`^(\+|\-) `, // Rule verdict.
|
`^(\+|\-) `, // Rule verdict.
|
||||||
|
`(! +)?`, // Invert matching.
|
||||||
`[A-z0-9\.:\-*/]+`, // Entity matching.
|
`[A-z0-9\.:\-*/]+`, // Entity matching.
|
||||||
`( `, // Start of optional matching.
|
`( `, // Start of optional matching.
|
||||||
`[A-z0-9*]+`, // Protocol matching.
|
`[A-z0-9*]+`, // Protocol matching.
|
||||||
`(/[A-z0-9]+(\-[A-z0-9]+)?)?`, // Port and port range matching.
|
`(/[A-z0-9]+(\-[A-z0-9]+)?)?`, // Port and port range matching.
|
||||||
`)?$`, // End of optional matching.
|
`)?`, // End of optional matching.
|
||||||
|
`( +#.*)?`, // Optional comment.
|
||||||
}, "")
|
}, "")
|
||||||
|
|
||||||
// ValidateEndpointListConfigOption validates the given value.
|
// ValidateEndpointListConfigOption validates the given value.
|
||||||
|
|
Loading…
Add table
Reference in a new issue