repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
fbf32b2
parent
907e5e8
author
Eric Bower
date
2022-08-08 03:26:03 +0000 UTC
fix(prose): init html policy once
1 files changed,  +7, -2
M prose/parser.go
+7, -2
 1@@ -30,7 +30,13 @@ type ParsedText struct {
 2 	*MetaData
 3 }
 4 
 5-var policy = bluemonday.UGCPolicy()
 6+func HtmlPolicy() *bluemonday.Policy {
 7+	policy := bluemonday.UGCPolicy()
 8+	policy.AllowStyling()
 9+	return policy
10+}
11+
12+var policy = HtmlPolicy()
13 
14 func toString(obj interface{}) string {
15 	if obj == nil {
16@@ -127,7 +133,6 @@ func ParseText(text string) (*ParsedText, error) {
17 		return &parsed, err
18 	}
19 
20-	policy.AllowStyling()
21 	parsed.Html = policy.Sanitize(buf.String())
22 	metaData := meta.Get(context)
23 	parsed.MetaData.Title = toString(metaData["title"])