aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-03-23 12:34:20 +0000
committerGitHub <noreply@github.com>2022-03-23 12:34:20 +0000
commit5248232c44f3819fbb8a6cdac258740afbb94823 (patch)
tree452852e66fdbc31dcc4fd89b063103b6c038e429 /modules
parent3f280f89e7471a6dcdaefccc64a8d39188970e63 (diff)
downloadgitea-5248232c44f3819fbb8a6cdac258740afbb94823.tar.gz
gitea-5248232c44f3819fbb8a6cdac258740afbb94823.zip
Try to prevent autolinking of displaynames by email readers (#19169)
Unfortunately many email readers will (helpfully) detect url or url-like names and automatically create links to them, even in HTML emails. This is not ideal when usernames can have dots in them. This PR tries to prevent this behaviour by sticking ZWJ characters between dots and also set the meta tag to prevent format detection. Not every email template has been changed in this way - just the activation emails but it may be that we should be setting the above meta tag in all of our emails too. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules')
-rw-r--r--modules/templates/helper.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 63c165bc8b..918a6523ba 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -632,6 +632,11 @@ func JSEscape(raw string) string {
return template.JSEscapeString(raw)
}
+// DotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent autolinkers from detecting these as urls
+func DotEscape(raw string) string {
+ return strings.ReplaceAll(raw, ".", "\u200d.\u200d")
+}
+
// Sha1 returns sha1 sum of string
func Sha1(str string) string {
return base.EncodeSha1(str)