mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Parse content warning to HTML, serialize via client API as plaintext (#3876)
* [feature] Parse content warning as HTML, serialize via API to plaintext * tidy up some cruft * whoops * oops * i'm da joker baybee * clemency muy lorde * rename some of the text functions for clarity * jiggle the opts * fiddle de deee * hopefully the last test fix i ever have to do in my beautiful life
This commit is contained in:
@ -28,7 +28,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/k3a/html2text"
|
||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
@ -247,7 +246,7 @@ func systemMessage(
|
||||
wrappedNote.WriteString(`<div class="gts-system-message `)
|
||||
wrappedNote.WriteString(messageClass)
|
||||
wrappedNote.WriteString(`">`)
|
||||
wrappedNote.WriteString(text.SanitizeToHTML(unsanitizedNoteHTML))
|
||||
wrappedNote.WriteString(text.SanitizeHTML(unsanitizedNoteHTML))
|
||||
wrappedNote.WriteString(`</div>`)
|
||||
|
||||
return wrappedNote.String()
|
||||
@ -380,15 +379,11 @@ func filterableFields(s *gtsmodel.Status) []string {
|
||||
|
||||
// Status content. Though we have raw text
|
||||
// available for statuses created on our
|
||||
// instance, use the html2text version to
|
||||
// instance, use the plaintext version to
|
||||
// remove markdown-formatting characters
|
||||
// and ensure more consistent filtering.
|
||||
if s.Content != "" {
|
||||
text := html2text.HTML2TextWithOptions(
|
||||
s.Content,
|
||||
html2text.WithLinksInnerText(),
|
||||
html2text.WithUnixLineBreaks(),
|
||||
)
|
||||
text := text.ParseHTMLToPlain(s.Content)
|
||||
if text != "" {
|
||||
fields = append(fields, text)
|
||||
}
|
||||
|
Reference in New Issue
Block a user