Prevent crash on empty title

This title, typed directly in the plain editor, would previously crash
the app / show the user a "server error":

# #
pull/506/head
Matt Baer 3 years ago
parent 3270470b68
commit 6ad1f41cf4
  1. 3
      postrender.go

@ -201,6 +201,9 @@ func applyBasicMarkdown(data []byte) string {
md := blackfriday.Markdown(append([]byte("# "), data...), blackfriday.HtmlRenderer(htmlFlags, "", ""), mdExtensions)
// Remove H1 markup
md = bytes.TrimSpace(md) // blackfriday.Markdown adds a newline at the end of the <h1>
if len(md) == 0 {
return ""
}
md = md[len("<h1>") : len(md)-len("</h1>")]
// Strip out bad HTML
policy := bluemonday.UGCPolicy()

Loading…
Cancel
Save