mirror of
https://github.com/writefreely/writefreely
synced 2024-11-10 11:24:13 +00:00
Prevent crash on empty title
This title, typed directly in the plain editor, would previously crash the app / show the user a "server error": # #
This commit is contained in:
parent
3270470b68
commit
6ad1f41cf4
1 changed files with 3 additions and 0 deletions
|
@ -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…
Reference in a new issue