Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Fix quotes issue in `TrackLink` regexp.

Kailash Nadhdc466fc76bde
diff --git a/models/models.go b/models/models.go
index 2f1d347b..8fb6c639 100644
--- a/models/models.go
+++ b/models/models.go
@@ -98,11 +98,11 @@ type regTplFunc struct {
var regTplFuncs = []regTplFunc{
// Regular expression for matching {{ TrackLink "http://link.com" }} in the template
- // and substituting it with {{ Track "http://link.com" . }} (the dot context)
+ // and substituting it with {{ TrackLink "http://link.com" . }} (the dot context)
// before compilation. This is to make linking easier for users.
{
- regExp: regexp.MustCompile(`{{(\s+)?TrackLink(\s+)?(.+?)(\s+)?}}`),
- replace: `{{ TrackLink $3 . }}`,
+ regExp: regexp.MustCompile(`{{\s*TrackLink\s+"([^"]+)"\s*}}`),
+ replace: `{{ TrackLink "$1" . }}`,
},
// Convert the shorthand https://google.com@TrackLink to {{ TrackLink ... }}.
@@ -543,6 +543,7 @@ func (c *Campaign) CompileTemplate(f template.FuncMap) error {
for _, r := range regTplFuncs {
body = r.regExp.ReplaceAllString(body, r.replace)
}
+
baseTPL, err := template.New(BaseTpl).Funcs(f).Parse(body)
if err != nil {
return fmt.Errorf("error compiling base template: %v", err)