From 54edb2562d19cadae760205e32a1c0c55cfe449a Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Thu, 14 Mar 2019 08:58:37 -0400 Subject: [PATCH] Strip HTML from post summary This removes HTML, in addition to the Markdown stripping that was already happening. This fixes #83 --- posts.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/posts.go b/posts.go index 6ae923d..4f5ca8d 100644 --- a/posts.go +++ b/posts.go @@ -18,6 +18,7 @@ import ( "github.com/guregu/null" "github.com/guregu/null/zero" "github.com/kylemcc/twitter-text-go/extract" + "github.com/microcosm-cc/bluemonday" stripmd "github.com/writeas/go-strip-markdown" "github.com/writeas/impart" "github.com/writeas/monday" @@ -205,6 +206,9 @@ func (p Post) Summary() string { if p.Content == "" { return "" } + // Strip out HTML + p.Content = bluemonday.StrictPolicy().Sanitize(p.Content) + // and Markdown p.Content = stripmd.Strip(p.Content) title := p.Title.String