aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2018-02-19 20:56:04 -0800
committerAdam Mathes <adam@trenchant.org>2018-02-19 20:56:04 -0800
commitd2ff568be0247c4a699a40e3d0eab7acb9499c2d (patch)
treefd4260f04b6faf5bf24be6ffacdd900fafba1ae2
parent0f005aa1013e14e8e054535fc4e81b4f1b319785 (diff)
downloadsnkt-d2ff568be0247c4a699a40e3d0eab7acb9499c2d.tar.gz
snkt-d2ff568be0247c4a699a40e3d0eab7acb9499c2d.tar.bz2
snkt-d2ff568be0247c4a699a40e3d0eab7acb9499c2d.zip
add SafeContent field to posts with sanitized content for RSS distribution
-rw-r--r--post/post.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/post/post.go b/post/post.go
index 1561161..7fa7e90 100644
--- a/post/post.go
+++ b/post/post.go
@@ -51,6 +51,9 @@ type Post struct {
// Content with sources and references resolved to absolute URLs
AbsoluteContent string
+ // AbsoluteContent with sanitizing for RSS feeds
+ SafeContent string
+
// Content HTML tags removed
PlainText string
@@ -196,7 +199,12 @@ func (p *Post) parse() {
//
p.Content = string(p.Filter([]byte(p.Text)))
p.AbsoluteContent = render.ResolveURLs(p.Content, p.Site.GetURL())
- policy := bluemonday.StrictPolicy()
+
+ policy := bluemonday.UGCPolicy()
+ policy.RequireNoFollowOnLinks(false)
+ p.SafeContent = policy.Sanitize(p.AbsoluteContent)
+
+ policy = bluemonday.StrictPolicy()
p.PlainText = policy.Sanitize(p.Content)
p.PlainText = strings.Replace(p.PlainText, "\n\n", "\n", -1)
p.PlainText = strings.Replace(p.PlainText, " ", " ", -1)