From 2b06679be667bee8107b5d0581cb88ede63f2e04 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Fri, 28 Apr 2023 02:43:29 +0200 Subject: [PATCH] Fix handling line separators BUG: 468977 --- autotests/texthandlertest.cpp | 9 +++++++++ src/texthandler.cpp | 1 + 2 files changed, 10 insertions(+) diff --git a/autotests/texthandlertest.cpp b/autotests/texthandlertest.cpp index a7de31615..d2fadd83f 100644 --- a/autotests/texthandlertest.cpp +++ b/autotests/texthandlertest.cpp @@ -63,6 +63,7 @@ private Q_SLOTS: void receiveRichEmote(); void receiveRichEdited_data(); void receiveRichEdited(); + void receiveLineSeparator(); }; #ifdef QUOTIENT_07 @@ -587,5 +588,13 @@ void TextHandlerTest::receiveRichEdited() QCOMPARE(testTextHandler.handleRecieveRichText(Qt::RichText, room, room->messageEvents().at(2).get()), testOutputString); } +void TextHandlerTest::receiveLineSeparator() +{ + auto text = QStringLiteral("foo\u2028bar"); + TextHandler textHandler; + textHandler.setData(text); + QCOMPARE(textHandler.handleRecievePlainText(Qt::PlainText, true), QStringLiteral("foo bar")); +} + QTEST_MAIN(TextHandlerTest) #include "texthandlertest.moc" diff --git a/src/texthandler.cpp b/src/texthandler.cpp index 5d6a1f576..9ee893557 100644 --- a/src/texthandler.cpp +++ b/src/texthandler.cpp @@ -213,6 +213,7 @@ QString TextHandler::handleRecievePlainText(Qt::TextFormat inputFormat, const bo m_dataBuffer.replace(QStringLiteral("
\n"), QStringLiteral(" ")); m_dataBuffer.replace(QStringLiteral("
"), QStringLiteral(" ")); m_dataBuffer.replace(u'\n', QStringLiteral(" ")); + m_dataBuffer.replace(u'\u2028', " "); } // Strip all tags/attributes except code blocks which will be escaped.