Parse template when validating it (#49282)
This commit is contained in:
@@ -2,6 +2,7 @@ package definitions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -74,6 +75,11 @@ func (t *MessageTemplate) Validate() error {
|
||||
return fmt.Errorf("template must have content")
|
||||
}
|
||||
|
||||
_, err := template.New("").Parse(t.Template)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid template: %w", err)
|
||||
}
|
||||
|
||||
content := strings.TrimSpace(t.Template)
|
||||
found, err := regexp.MatchString(`\{\{\s*define`, content)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user