2020-01-08 13:25:46 +00:00
|
|
|
package koushinbase
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/microcosm-cc/bluemonday"
|
|
|
|
)
|
|
|
|
|
2020-01-08 13:30:00 +00:00
|
|
|
func sanitizeHTML(b []byte) []byte {
|
2020-01-08 13:25:46 +00:00
|
|
|
p := bluemonday.UGCPolicy()
|
|
|
|
|
|
|
|
// TODO: be more strict
|
|
|
|
p.AllowElements("style")
|
|
|
|
p.AllowAttrs("style")
|
|
|
|
|
|
|
|
p.AddTargetBlankToFullyQualifiedLinks(true)
|
|
|
|
p.RequireNoFollowOnLinks(true)
|
|
|
|
|
2020-01-08 13:30:00 +00:00
|
|
|
return p.SanitizeBytes(b)
|
2020-01-08 13:25:46 +00:00
|
|
|
}
|