mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Validate Keep list and Block list rules syntax
This commit is contained in:
parent
05fd83bd6f
commit
e8d0360e64
19 changed files with 173 additions and 23 deletions
|
@ -15,7 +15,7 @@ func ValidateFeedCreation(store *storage.Storage, userID int64, request *model.F
|
|||
return NewValidationError("error.feed_mandatory_fields")
|
||||
}
|
||||
|
||||
if !isValidURL(request.FeedURL) {
|
||||
if !IsValidURL(request.FeedURL) {
|
||||
return NewValidationError("error.invalid_feed_url")
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,14 @@ func ValidateFeedCreation(store *storage.Storage, userID int64, request *model.F
|
|||
return NewValidationError("error.feed_category_not_found")
|
||||
}
|
||||
|
||||
if !IsValidRegex(request.BlocklistRules) {
|
||||
return NewValidationError("error.feed_invalid_blocklist_rule")
|
||||
}
|
||||
|
||||
if !IsValidRegex(request.KeeplistRules) {
|
||||
return NewValidationError("error.feed_invalid_keeplist_rule")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -37,7 +45,7 @@ func ValidateFeedModification(store *storage.Storage, userID int64, request *mod
|
|||
return NewValidationError("error.feed_url_not_empty")
|
||||
}
|
||||
|
||||
if !isValidURL(*request.FeedURL) {
|
||||
if !IsValidURL(*request.FeedURL) {
|
||||
return NewValidationError("error.invalid_feed_url")
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +55,7 @@ func ValidateFeedModification(store *storage.Storage, userID int64, request *mod
|
|||
return NewValidationError("error.site_url_not_empty")
|
||||
}
|
||||
|
||||
if !isValidURL(*request.SiteURL) {
|
||||
if !IsValidURL(*request.SiteURL) {
|
||||
return NewValidationError("error.invalid_site_url")
|
||||
}
|
||||
}
|
||||
|
@ -64,5 +72,17 @@ func ValidateFeedModification(store *storage.Storage, userID int64, request *mod
|
|||
}
|
||||
}
|
||||
|
||||
if request.BlocklistRules != nil {
|
||||
if !IsValidRegex(*request.BlocklistRules) {
|
||||
return NewValidationError("error.feed_invalid_blocklist_rule")
|
||||
}
|
||||
}
|
||||
|
||||
if request.KeeplistRules != nil {
|
||||
if !IsValidRegex(*request.KeeplistRules) {
|
||||
return NewValidationError("error.feed_invalid_keeplist_rule")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue