Merge branch 'main' of github.com:binwiederhier/ntfy into predefined-users
This commit is contained in:
@@ -1001,7 +1001,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
|
||||
}
|
||||
@@ -1043,7 +1050,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" {
|
||||
@@ -1208,7 +1214,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 {
|
||||
|
||||
Reference in New Issue
Block a user