mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-28 09:13:09 -06:00
Appservice config: handle regexp parsing errors
Signed-off-by: diamondburned <datutbrus@gmail.com> Signed-off-by: Bohdan Horbeshko <bodqhrohro@gmail.com>
This commit is contained in:
parent
9d435bb559
commit
96f5bc1f7e
|
|
@ -224,7 +224,7 @@ func setupRegexps(asAPI *AppServiceAPI, derived *Derived) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = compileNamespaceRegexes(namespaceSlice); err != nil {
|
if err = compileNamespaceRegexes(namespaceSlice); err != nil {
|
||||||
return err
|
return fmt.Errorf("invalid regex in appservice %q, namespace %q: %w", appservice.ID, key, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -276,9 +276,12 @@ func appendExclusiveNamespaceRegexs(
|
||||||
func compileNamespaceRegexes(namespaces []ApplicationServiceNamespace) (err error) {
|
func compileNamespaceRegexes(namespaces []ApplicationServiceNamespace) (err error) {
|
||||||
for index, namespace := range namespaces {
|
for index, namespace := range namespaces {
|
||||||
// Compile this regex into a Regexp object for later use
|
// Compile this regex into a Regexp object for later use
|
||||||
if namespaces[index].RegexpObject, err = regexp.Compile(namespace.Regex); err != nil {
|
r, err := regexp.Compile(namespace.Regex)
|
||||||
return err
|
if err != nil {
|
||||||
|
return fmt.Errorf("regex at namespace %d: %w", index, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespaces[index].RegexpObject = r
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue