diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2023-04-14 13:35:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 12:35:27 +0100 |
commit | c45d8cd68875f7f5081f252cfdc2dd32f99c58f8 (patch) | |
tree | ee3d2fd0df11fc7bebc0d57ffa6040c5fb2bd203 /internal | |
parent | ca63b414da87f7bdb25effffd187d51191a42b3e (diff) |
Add pushrules tests (#3044)
partly takes care of https://github.com/matrix-org/dendrite/issues/2870
by making sure that rule IDs don't start with a dot.
Co-authored-by: kegsay <kegan@matrix.org>
Diffstat (limited to 'internal')
-rw-r--r-- | internal/pushrules/validate.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/internal/pushrules/validate.go b/internal/pushrules/validate.go index f50c51bd..b54ec3fb 100644 --- a/internal/pushrules/validate.go +++ b/internal/pushrules/validate.go @@ -10,6 +10,10 @@ import ( func ValidateRule(kind Kind, rule *Rule) []error { var errs []error + if len(rule.RuleID) > 0 && rule.RuleID[:1] == "." { + errs = append(errs, fmt.Errorf("invalid rule ID: rule can not start with a dot")) + } + if !validRuleIDRE.MatchString(rule.RuleID) { errs = append(errs, fmt.Errorf("invalid rule ID: %s", rule.RuleID)) } |