Handle escaped html for plain text output
Always unescape html for plain text output no matter what the input is.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "texthandler.h"
|
||||
|
||||
#include <connection.h>
|
||||
#include <qnamespace.h>
|
||||
#include <quotient_common.h>
|
||||
#include <syncdata.h>
|
||||
|
||||
@@ -49,7 +49,8 @@ private Q_SLOTS:
|
||||
void receiveStripReply();
|
||||
void receivePlainTextIn();
|
||||
|
||||
void recieveRichInPlainOut();
|
||||
void receiveRichInPlainOut_data();
|
||||
void receiveRichInPlainOut();
|
||||
void receivePlainStripHtml();
|
||||
void receivePlainStripMarkup();
|
||||
void receiveStripNewlines();
|
||||
@@ -349,15 +350,24 @@ void TextHandlerTest::receiveStripReply()
|
||||
QCOMPARE(testTextHandler.handleRecievePlainText(), testOutputString);
|
||||
}
|
||||
|
||||
void TextHandlerTest::recieveRichInPlainOut()
|
||||
void TextHandlerTest::receiveRichInPlainOut_data()
|
||||
{
|
||||
const QString testInputString = QStringLiteral("a & b");
|
||||
const QString testOutputString = QStringLiteral("a & b");
|
||||
QTest::addColumn<QString>("testInputString");
|
||||
QTest::addColumn<QString>("testOutputString");
|
||||
|
||||
QTest::newRow("ampersand") << QStringLiteral("a & b") << QStringLiteral("a & b");
|
||||
QTest::newRow("quote") << QStringLiteral(""a and b"") << QStringLiteral("\"a and b\"");
|
||||
}
|
||||
|
||||
void TextHandlerTest::receiveRichInPlainOut()
|
||||
{
|
||||
QFETCH(QString, testInputString);
|
||||
QFETCH(QString, testOutputString);
|
||||
|
||||
TextHandler testTextHandler;
|
||||
testTextHandler.setData(testInputString);
|
||||
|
||||
QCOMPARE(testTextHandler.handleRecievePlainText(), testOutputString);
|
||||
QCOMPARE(testTextHandler.handleRecievePlainText(Qt::RichText), testOutputString);
|
||||
}
|
||||
|
||||
void TextHandlerTest::receivePlainTextIn()
|
||||
|
||||
@@ -235,9 +235,7 @@ QString TextHandler::handleRecievePlainText(Qt::TextFormat inputFormat, const bo
|
||||
|
||||
// Escaping then unescaping allows < and > to be maintained in a plain text string
|
||||
// otherwise markdownToHTML will strip what it thinks is a bad html tag entirely.
|
||||
if (inputFormat == Qt::PlainText) {
|
||||
outputString = unescapeHtml(outputString);
|
||||
}
|
||||
outputString = unescapeHtml(outputString);
|
||||
|
||||
outputString = outputString.trimmed();
|
||||
return outputString;
|
||||
|
||||
Reference in New Issue
Block a user