Strip HTML from post summary

This removes HTML, in addition to the Markdown stripping that was
already happening.

This fixes #83
This commit is contained in:
Matt Baer 2019-03-14 08:58:37 -04:00
parent 2f683e783e
commit 54edb2562d
1 changed files with 4 additions and 0 deletions

View File

@ -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