diff options
author | Adam Mathes <adam@trenchant.org> | 2018-02-19 20:56:04 -0800 |
---|---|---|
committer | Adam Mathes <adam@trenchant.org> | 2018-02-19 20:56:04 -0800 |
commit | d2ff568be0247c4a699a40e3d0eab7acb9499c2d (patch) | |
tree | fd4260f04b6faf5bf24be6ffacdd900fafba1ae2 /post | |
parent | 0f005aa1013e14e8e054535fc4e81b4f1b319785 (diff) | |
download | snkt-d2ff568be0247c4a699a40e3d0eab7acb9499c2d.tar.gz snkt-d2ff568be0247c4a699a40e3d0eab7acb9499c2d.tar.bz2 snkt-d2ff568be0247c4a699a40e3d0eab7acb9499c2d.zip |
add SafeContent field to posts with sanitized content for RSS distribution
Diffstat (limited to 'post')
-rw-r--r-- | post/post.go | 10 |
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) |