Prevent out of bounds error when post has no title

This commit is contained in:
Matt Baer 2021-06-23 17:38:22 -04:00
parent 0ddca40529
commit f933b36170
2 changed files with 5 additions and 0 deletions

View file

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

View file

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