mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +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
|
@ -58,10 +58,12 @@ func (h *handler) updateFeed(w http.ResponseWriter, r *http.Request) {
|
|||
view.Set("defaultUserAgent", config.Opts.HTTPClientUserAgent())
|
||||
|
||||
feedModificationRequest := &model.FeedModificationRequest{
|
||||
FeedURL: model.OptionalString(feedForm.FeedURL),
|
||||
SiteURL: model.OptionalString(feedForm.SiteURL),
|
||||
Title: model.OptionalString(feedForm.Title),
|
||||
CategoryID: model.OptionalInt64(feedForm.CategoryID),
|
||||
FeedURL: model.OptionalString(feedForm.FeedURL),
|
||||
SiteURL: model.OptionalString(feedForm.SiteURL),
|
||||
Title: model.OptionalString(feedForm.Title),
|
||||
CategoryID: model.OptionalInt64(feedForm.CategoryID),
|
||||
BlocklistRules: model.OptionalString(feedForm.BlocklistRules),
|
||||
KeeplistRules: model.OptionalString(feedForm.KeeplistRules),
|
||||
}
|
||||
|
||||
if validationErr := validator.ValidateFeedModification(h.store, loggedUser.ID, feedModificationRequest); validationErr != nil {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"miniflux.app/errors"
|
||||
"miniflux.app/validator"
|
||||
)
|
||||
|
||||
// SubscriptionForm represents the subscription form.
|
||||
|
@ -32,6 +33,18 @@ func (s *SubscriptionForm) Validate() error {
|
|||
return errors.NewLocalizedError("error.feed_mandatory_fields")
|
||||
}
|
||||
|
||||
if !validator.IsValidURL(s.URL) {
|
||||
return errors.NewLocalizedError("error.invalid_feed_url")
|
||||
}
|
||||
|
||||
if !validator.IsValidRegex(s.BlocklistRules) {
|
||||
return errors.NewLocalizedError("error.feed_invalid_blocklist_rule")
|
||||
}
|
||||
|
||||
if !validator.IsValidRegex(s.KeeplistRules) {
|
||||
return errors.NewLocalizedError("error.feed_invalid_keeplist_rule")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue