From 925e20ebb8a99f9ed99992f81fc5d8d846f5af75 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sun, 19 Mar 2023 19:58:56 +0000 Subject: [PATCH] Handle quotes in plain strings Unescape quotes in plain strings --- autotests/texthandlertest.cpp | 8 ++++++++ src/texthandler.cpp | 1 + 2 files changed, 9 insertions(+) diff --git a/autotests/texthandlertest.cpp b/autotests/texthandlertest.cpp index 44c43e37b..d56e4c379 100644 --- a/autotests/texthandlertest.cpp +++ b/autotests/texthandlertest.cpp @@ -326,11 +326,19 @@ void TextHandlerTest::receivePlainTextIn() const QString testOutputStringRich = QStringLiteral("<plain text in tag bracket>
Test link https://kde.org."); QString testOutputStringPlain = QStringLiteral("\nTest link https://kde.org."); + // Make sure quotes are maintained in a plain string. + const QString testInputString2 = QStringLiteral("last line is \"Time to switch to a new topic.\""); + const QString testOutputString2 = QStringLiteral("last line is \"Time to switch to a new topic.\""); + TextHandler testTextHandler; testTextHandler.setData(testInputString); QCOMPARE(testTextHandler.handleRecieveRichText(Qt::PlainText), testOutputStringRich); QCOMPARE(testTextHandler.handleRecievePlainText(), testOutputStringPlain); + + testTextHandler.setData(testInputString2); + QCOMPARE(testTextHandler.handleRecieveRichText(Qt::PlainText), testOutputString2); + QCOMPARE(testTextHandler.handleRecievePlainText(), testOutputString2); } void TextHandlerTest::receiveStripNewlines() diff --git a/src/texthandler.cpp b/src/texthandler.cpp index f6e6ff8a2..102116f72 100644 --- a/src/texthandler.cpp +++ b/src/texthandler.cpp @@ -371,6 +371,7 @@ QString TextHandler::unescapeHtml(QString stringIn) stringIn.replace(QStringLiteral("<"), QStringLiteral("<")); stringIn.replace(QStringLiteral(">"), QStringLiteral(">")); stringIn.replace(QStringLiteral("&"), QStringLiteral("&")); + stringIn.replace(QStringLiteral("""), QStringLiteral("\"")); return stringIn; }