From d8113c11e4d84a6d04d56b58d337c235154a535b Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 7 Mar 2025 15:04:34 +0100 Subject: [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 --- internal/typeutils/util.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'internal/typeutils/util.go') diff --git a/internal/typeutils/util.go b/internal/typeutils/util.go index b4f2e41aa..17394fe49 100644 --- a/internal/typeutils/util.go +++ b/internal/typeutils/util.go @@ -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(`
`) - wrappedNote.WriteString(text.SanitizeToHTML(unsanitizedNoteHTML)) + wrappedNote.WriteString(text.SanitizeHTML(unsanitizedNoteHTML)) wrappedNote.WriteString(`
`) 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) } -- cgit v1.2.3