Prevent out of bounds error when post has no title

pull/471/head
Matt Baer 3 years ago
parent 0ddca40529
commit f933b36170
  1. 4
      postrender.go
  2. 1
      postrender_test.go

@ -182,6 +182,10 @@ func applyMarkdownSpecial(data []byte, skipNoFollow bool, baseURL string, cfg *c
} }
func applyBasicMarkdown(data []byte) string { func applyBasicMarkdown(data []byte) string {
if len(data) == 0 {
return ""
}
mdExtensions := 0 | mdExtensions := 0 |
blackfriday.EXTENSION_STRIKETHROUGH | blackfriday.EXTENSION_STRIKETHROUGH |
blackfriday.EXTENSION_SPACE_HEADERS | blackfriday.EXTENSION_SPACE_HEADERS |

@ -18,6 +18,7 @@ func TestApplyBasicMarkdown(t *testing.T) {
in string in string
result string result string
}{ }{
{"empty", "", ""},
{"plain", "Hello, World!", "Hello, World!"}, {"plain", "Hello, World!", "Hello, World!"},
{"multibyte", "こんにちは", `こんにちは`}, {"multibyte", "こんにちは", `こんにちは`},
{"bold", "**안녕하세요**", `<strong>안녕하세요</strong>`}, {"bold", "**안녕하세요**", `<strong>안녕하세요</strong>`},

Loading…
Cancel
Save