Skip to content

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

Fix too greedy TrackLink regex replacement. (#2355)

Fabian Schneebauer7d3e6e615a9c
diff --git a/models/models.go b/models/models.go
index 3a8c9a00..42604771 100644
--- a/models/models.go
+++ b/models/models.go
@@ -116,8 +116,10 @@ var regTplFuncs = []regTplFunc{
// Convert the shorthand https://google.com@TrackLink to {{ TrackLink ... }}.
// This is for WYSIWYG editors that encode and break quotes {{ "" }} when inserted
// inside <a href="{{ TrackLink "https://these-quotes-break" }}>.
+ // The regex matches all characters that may occur in an URL
+ // (see "2. Characters" in RFC3986: https://www.ietf.org/rfc/rfc3986.txt)
{
- regExp: regexp.MustCompile(`(https?://.+?)@TrackLink`),
+ regExp: regexp.MustCompile(`(https?://[\p{L}_\-\.~!#$&'()*+,/:;=?@\[\]]*)@TrackLink`),
replace: `{{ TrackLink "$1" . }}`,
},