From d2ff568be0247c4a699a40e3d0eab7acb9499c2d Mon Sep 17 00:00:00 2001
From: Adam Mathes <adam@trenchant.org>
Date: Mon, 19 Feb 2018 20:56:04 -0800
Subject: add SafeContent field to posts with sanitized content for RSS
 distribution

---
 post/post.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'post')

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)
-- 
cgit v1.2.3