|
|
@@ -991,7 +991,14 @@ func (s *Server) parsePublishParams(r *http.Request, m *message) (cache bool, fi
|
|
|
} else if call != "" && !isBoolValue(call) && !phoneNumberRegex.MatchString(call) {
|
|
|
return false, false, "", "", "", false, errHTTPBadRequestPhoneNumberInvalid
|
|
|
}
|
|
|
- messageStr := strings.ReplaceAll(readParam(r, "x-message", "message", "m"), "\\n", "\n")
|
|
|
+ template = templateMode(readParam(r, "x-template", "template", "tpl"))
|
|
|
+ var messageStr string
|
|
|
+ if template.Enabled() && template.Name() == "" {
|
|
|
+ // don't convert "\n" to literal newline for inline templates
|
|
|
+ messageStr = readParam(r, "x-message", "message", "m")
|
|
|
+ } else {
|
|
|
+ messageStr = strings.ReplaceAll(readParam(r, "x-message", "message", "m"), "\\n", "\n")
|
|
|
+ }
|
|
|
if messageStr != "" {
|
|
|
m.Message = messageStr
|
|
|
}
|
|
|
@@ -1033,7 +1040,6 @@ func (s *Server) parsePublishParams(r *http.Request, m *message) (cache bool, fi
|
|
|
if markdown || strings.ToLower(contentType) == "text/markdown" {
|
|
|
m.ContentType = "text/markdown"
|
|
|
}
|
|
|
- template = templateMode(readParam(r, "x-template", "template", "tpl"))
|
|
|
unifiedpush = readBoolParam(r, false, "x-unifiedpush", "unifiedpush", "up") // see GET too!
|
|
|
contentEncoding := readParam(r, "content-encoding")
|
|
|
if unifiedpush || contentEncoding == "aes128gcm" {
|
|
|
@@ -1198,7 +1204,7 @@ func (s *Server) renderTemplate(tpl string, source string) (string, error) {
|
|
|
if err := t.Execute(limitWriter, data); err != nil {
|
|
|
return "", errHTTPBadRequestTemplateExecuteFailed.Wrap("%s", err.Error())
|
|
|
}
|
|
|
- return strings.TrimSpace(buf.String()), nil
|
|
|
+ return strings.TrimSpace(strings.ReplaceAll(buf.String(), "\\n", "\n")), nil // replace any remaining "\n" (those outside of template curly braces) with newlines
|
|
|
}
|
|
|
|
|
|
func (s *Server) handleBodyAsAttachment(r *http.Request, v *visitor, m *message, body *util.PeekedReadCloser) error {
|