diff --git a/utils/sanitize/markdown.go b/utils/sanitize/markdown.go index f515c6fa..d6338526 100644 --- a/utils/sanitize/markdown.go +++ b/utils/sanitize/markdown.go @@ -310,6 +310,7 @@ func repairHTMLTags(brokenHTML string) string { // ParseBBCodes returns the bbcode compiler with the bbcode tags to parse func ParseBBCodes(msg string) string { msg = BBCodesRenderer.Compile(msg) + msg = strings.Replace(msg, "
", "\n", -1) // For some reason, BBCodes compiler return escaped html // We need to unescape it return html.UnescapeString(msg) diff --git a/utils/sanitize/markdown_test.go b/utils/sanitize/markdown_test.go index eb40a79b..56e97f40 100644 --- a/utils/sanitize/markdown_test.go +++ b/utils/sanitize/markdown_test.go @@ -36,6 +36,7 @@ func TestParseBBCodes(t *testing.T) { {"", ""}, {">", ">"}, // keep escaped html {"lol", "lol"}, // keep html tags + {"ddd\nddd", "ddd\nddd"}, // keep html tags {"[b]lol[/b]", "lol"}, // Convert bbcodes {"[u][b]lol[/u]", "lol"}, // Close unclosed tags } @@ -71,7 +72,8 @@ func TestSanitize(t *testing.T) { Result string }{ {"", ""}, - {"[b]lol[/b]", "lol"}, // Should convert bbcodes + {"[b]lol[/b]", "lol"}, // Should convert bbcodes + {"ddd\nddd", "ddd\nddd"}, {">", ">"}, // keep escaped html {"lol", "lol"}, // keep html tags {"lol", "lol"}, // close unclosed tags encapsulated