// GoToSocial
// Copyright (C) GoToSocial Authors admin@gotosocial.org
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see
this is a plain and simple status
" simpleExpectedNoParagraph = "this is a plain and simple status" withTag = "here's a simple status that uses hashtag #welcome!" withTagExpected = "here's a simple status that uses hashtag #welcome!
" withTagExpectedNoParagraph = "here's a simple status that uses hashtag #welcome!" withHTML = "<div>blah this should just be html escaped blah</div>
" moreComplex = "Another test @foss_satan@fossbros-anonymous.io\n\n#Hashtag\n\nText\n\n:rainbow:" moreComplexExpected = "Another test @foss_satan
#Hashtag
Text
:rainbow:
here's a link with utf-8 characters in it: https://example.org/söme_url
" withFunkyTags = "#hashtag1 pee #hashtag2\u200Bpee #hashtag3|poo #hashtag4\uFEFFpoo" withFunkyTagsExpected = "#hashtag1 pee #hashtag2\u200bpee #hashtag3|poo #hashtag4\ufeffpoo
" ) type PlainTestSuite struct { TextStandardTestSuite } func (suite *PlainTestSuite) TestParseSimple() { formatted := suite.FromPlain(simple) suite.Equal(simpleExpected, formatted.HTML) } func (suite *PlainTestSuite) TestParseSimpleNoParagraph() { formatted := suite.FromPlainNoParagraph(simple) suite.Equal(simpleExpectedNoParagraph, formatted.HTML) } func (suite *PlainTestSuite) TestParseWithTag() { formatted := suite.FromPlain(withTag) suite.Equal(withTagExpected, formatted.HTML) } func (suite *PlainTestSuite) TestParseWithTagNoParagraph() { formatted := suite.FromPlainNoParagraph(withTag) suite.Equal(withTagExpectedNoParagraph, formatted.HTML) } func (suite *PlainTestSuite) TestParseWithHTML() { formatted := suite.FromPlain(withHTML) suite.Equal(withHTMLExpected, formatted.HTML) } func (suite *PlainTestSuite) TestParseMoreComplex() { formatted := suite.FromPlain(moreComplex) suite.Equal(moreComplexExpected, formatted.HTML) } func (suite *PlainTestSuite) TestWithUTF8Link() { formatted := suite.FromPlain(withUTF8Link) suite.Equal(withUTF8LinkExpected, formatted.HTML) } func (suite *PlainTestSuite) TestLinkNoMention() { statusText := `here's a link to a post by zork https://example.com/@the_mighty_zork/statuses/01FGVP55XMF2K6316MQRX6PFG1 that link shouldn't come out formatted as a mention!` menchies := suite.FromPlain(statusText).Mentions suite.Empty(menchies) } func (suite *PlainTestSuite) TestDeriveMentionsEmpty() { statusText := `` menchies := suite.FromPlain(statusText).Mentions suite.Len(menchies, 0) } func (suite *PlainTestSuite) TestDeriveHashtagsOK() { statusText := `weeeeeeee #testing123 #also testing # testing this one shouldn't work #thisshouldwork #dupe #dupe!! #dupe here's a link with a fragment: https://example.org/whatever#ahhh here's another link with a fragment: https://example.org/whatever/#ahhh (#ThisShouldAlsoWork) #this_should_not_be_split #__ <- just underscores, shouldn't work #111111 thisalsoshouldn'twork#### ## #alimentación, #saúde, #lävistää, #ö, #네 #ThisOneIsOneHundredAndOneCharactersLongWhichIsReallyJustWayWayTooLongDefinitelyLongerThanYouWouldNeed... #ThisOneIsThirteyCharactersLong ` tags := suite.FromPlain(statusText).Tags if suite.Len(tags, 12) { suite.Equal("testing123", tags[0].Name) suite.Equal("also", tags[1].Name) suite.Equal("thisshouldwork", tags[2].Name) suite.Equal("dupe", tags[3].Name) suite.Equal("ThisShouldAlsoWork", tags[4].Name) suite.Equal("this_should_not_be_split", tags[5].Name) suite.Equal("alimentación", tags[6].Name) suite.Equal("saúde", tags[7].Name) suite.Equal("lävistää", tags[8].Name) suite.Equal("ö", tags[9].Name) suite.Equal("네", tags[10].Name) suite.Equal("ThisOneIsThirteyCharactersLong", tags[11].Name) } statusText = `#올빼미 hej` tags = suite.FromPlain(statusText).Tags suite.Equal("올빼미", tags[0].Name) } func (suite *PlainTestSuite) TestFunkyTags() { formatted := suite.FromPlain(withFunkyTags) suite.Equal(withFunkyTagsExpected, formatted.HTML) tags := formatted.Tags suite.Equal("hashtag1", tags[0].Name) suite.Equal("hashtag2", tags[1].Name) suite.Equal("hashtag3", tags[2].Name) suite.Equal("hashtag4", tags[3].Name) } func (suite *PlainTestSuite) TestDeriveMultiple() { statusText := `Another test @foss_satan@fossbros-anonymous.io #Hashtag Text` f := suite.FromPlain(statusText) suite.Len(f.Mentions, 1) suite.Equal("@foss_satan@fossbros-anonymous.io", f.Mentions[0].NameString) suite.Len(f.Tags, 1) suite.Equal("hashtag", f.Tags[0].Name) suite.Len(f.Emojis, 0) } func (suite *PlainTestSuite) TestZalgoHashtag() { statusText := `yo who else loves #praying to #z̸͉̅a̸͚͋l̵͈̊g̸̫͌ỏ̷̪?` f := suite.FromPlain(statusText) if suite.Len(f.Tags, 2) { suite.Equal("praying", f.Tags[0].Name) // NFC doesn't do much for Zalgo text, but it's difficult to strip marks without affecting non-Latin text. suite.Equal("z̸͉̅a̸͚͋l̵͈̊g̸̫͌ỏ̷̪", f.Tags[1].Name) } } func (suite *PlainTestSuite) TestNumbersAreNotHashtags() { statusText := `yo who else thinks #19_98 is #1?` f := suite.FromPlain(statusText) suite.Len(f.Tags, 0) } func (suite *PlainTestSuite) TestHTMLToPlain() { for _, t := range []struct { html string expectedPlain string }{ { // Check newlines between paras preserved. html: "butting into a serious discussion about programming languages*: \"elixir? I barely know 'er! honk honk!\"
*insofar as any discussion about programming languages can truly be considered \"serious\" since programmers are fucking clowns
", expectedPlain: `butting into a serious discussion about programming languages*: "elixir? I barely know 'er! honk honk!" *insofar as any discussion about programming languages can truly be considered "serious" since programmers are fucking clowns`, }, { // This one looks a bit wacky but nobody should // be putting definition lists in summaries *really*. html: "i'm a milf,
i'm a lover,
do your mom,
do your brother
i'm a sinner,
i'm a saint,
i will not be ashamed!
Hello everyone, after a week or two down the release candidate mines, we've emerged blinking into the light carrying with us #GoToSocial v0.18.0 Scroingly Sloth!
https://github.com/superseriousbusiness/gotosocial/releases/tag/v0.18.0
Please read the migration notes carefully for instructions on how to upgrade to this version. This version contains several very long migrations so you will need to be patient when upgrading, and backup your database first!!
Release highlights
instance-stats-mode setting, admins can now choose if and how their instance serves stats via the nodeinfo endpoints. Existing behavior from v0.17.0 is the default.prefers-color-scheme preference: there's now a light mode default theme to complement our trusty dark mode theme, and the theme will switch based on a visitor's prefers-color-scheme configuration. This applies to all page and profiles, with the exception of some custom themes. Works in the settings panel too!Thanks for reading! And seriously back up your database.
", expectedPlain: `Hello everyone, after a week or two down the release candidate mines, we've emerged blinking into the light carrying with us #GoToSocial