Federated via graft
0

Configure Feed

Select the types of activity you want to include in your feed.

1package activitypub 2 3import ( 4 "html" 5 "regexp" 6 "strings" 7) 8 9var ( 10 tagRe = regexp.MustCompile(`<[^>]*>`) 11 blockEndRe = regexp.MustCompile(`</(p|br|div)\s*>`) 12) 13 14// stripHTML turns Mastodon's rich-text Note content (HTML, e.g. 15// "<p>hello <a href=...>@bot</a></p>") into plain text suitable for a 16// Forgejo/Radicle comment body. Not a sanitizer — this only ever displays 17// the result as inert markdown-adjacent plain text, never re-renders it as 18// HTML, so no XSS surface is introduced by skipping a full parser here. 19func stripHTML(s string) string { 20 s = blockEndRe.ReplaceAllString(s, "\n") 21 s = tagRe.ReplaceAllString(s, "") 22 s = html.UnescapeString(s) 23 return strings.TrimSpace(s) 24}