diff options
| author | 2025-03-07 15:04:34 +0100 | |
|---|---|---|
| committer | 2025-03-07 14:04:34 +0000 | |
| commit | d8113c11e4d84a6d04d56b58d337c235154a535b (patch) | |
| tree | 3ed983cbb8f95c9ef51a02a51a50ab89c42abd14 /internal/typeutils/util.go | |
| parent | [bugfix] Store and expose status content type (#3870) (diff) | |
| download | gotosocial-d8113c11e4d84a6d04d56b58d337c235154a535b.tar.xz | |
[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
Diffstat (limited to 'internal/typeutils/util.go')
| -rw-r--r-- | internal/typeutils/util.go | 11 |
1 files changed, 3 insertions, 8 deletions
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(`<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) } |
