aboutsummaryrefslogtreecommitdiffstats
path: root/lib/templates
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-04-23 20:55:18 +0200
committerDrew DeVault <sir@cmpwn.com>2020-04-24 12:59:21 -0400
commitacf69b7490f4848066f2df4b3c2f675a8d57661a (patch)
treeb3442983879619331b753c4edfc2dcbdd8c746b6 /lib/templates
parent3fa9ae3edb0c2193ef333a77b710ccbe54ee4368 (diff)
downloadaerc-acf69b7490f4848066f2df4b3c2f675a8d57661a.tar.gz
Remove ability to specify headers in the editor
Due to headers being essentially free text, we constantly run into issues with parts of the body being interpreted as headers. Remove the ability to overwrite headers to avoid that, while keeping the ability to specify headers in the template files. Fixes #383
Diffstat (limited to 'lib/templates')
-rw-r--r--lib/templates/template.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/templates/template.go b/lib/templates/template.go
index 9df594eb..e18328cc 100644
--- a/lib/templates/template.go
+++ b/lib/templates/template.go
@@ -3,6 +3,7 @@ package templates
import (
"bytes"
"errors"
+ "io"
"net/mail"
"os"
"os/exec"
@@ -185,7 +186,7 @@ func findTemplate(templateName string, templateDirs []string) (string, error) {
return "", errors.New("Can't find template - " + templateName)
}
-func ParseTemplateFromFile(templateName string, templateDirs []string, data interface{}) ([]byte, error) {
+func ParseTemplateFromFile(templateName string, templateDirs []string, data interface{}) (io.Reader, error) {
templateFile, err := findTemplate(templateName, templateDirs)
if err != nil {
return nil, err
@@ -196,11 +197,11 @@ func ParseTemplateFromFile(templateName string, templateDirs []string, data inte
return nil, err
}
- var outString bytes.Buffer
- if err := emailTemplate.Execute(&outString, data); err != nil {
+ var body bytes.Buffer
+ if err := emailTemplate.Execute(&body, data); err != nil {
return nil, err
}
- return outString.Bytes(), nil
+ return &body, nil
}
func ParseTemplate(templateText string, data interface{}) ([]byte, error) {