1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

Validate Keep list and Block list rules syntax

This commit is contained in:
Frédéric Guillot 2021-02-07 18:38:45 -08:00 committed by fguillot
parent 05fd83bd6f
commit e8d0360e64
19 changed files with 173 additions and 23 deletions

View file

@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"net/url"
"regexp"
"miniflux.app/locale"
)
@ -53,7 +54,14 @@ func ValidateDirection(direction string) error {
return fmt.Errorf(`Invalid direction, valid direction values are: "asc" or "desc"`)
}
func isValidURL(absoluteURL string) bool {
// IsValidRegex verifies if the regex can be compiled.
func IsValidRegex(expr string) bool {
_, err := regexp.Compile(expr)
return err == nil
}
// IsValidURL verifies if the provided value is a valid absolute URL.
func IsValidURL(absoluteURL string) bool {
_, err := url.ParseRequestURI(absoluteURL)
return err == nil
}