From f933b3617086a7995e81855be14576cfc51d8f43 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 23 Jun 2021 17:38:22 -0400 Subject: [PATCH] Prevent out of bounds error when post has no title --- postrender.go | 4 ++++ postrender_test.go | 1 + 2 files changed, 5 insertions(+) diff --git a/postrender.go b/postrender.go index 0992d30..1cb4f0e 100644 --- a/postrender.go +++ b/postrender.go @@ -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 | diff --git a/postrender_test.go b/postrender_test.go index 240e755..262d550 100644 --- a/postrender_test.go +++ b/postrender_test.go @@ -18,6 +18,7 @@ func TestApplyBasicMarkdown(t *testing.T) { in string result string }{ + {"empty", "", ""}, {"plain", "Hello, World!", "Hello, World!"}, {"multibyte", "こんにちは", `こんにちは`}, {"bold", "**안녕하세요**", `안녕하세요`},