#include
#include "htmlbuilder.h"
class TestHtmlBuilder : public QObject
{
Q_OBJECT
private slots:
void escapesPlainText();
void preservesHtmlBodyWhenHtmlRequested();
void marksQuotedLines();
void plainTextScriptTagIsNeutralised();
void buildsThreadWithAllMessages();
void collapsedMessageShowsStubOnly();
void threadNamespacesCidUrls();
// Adversarial additions.
void namespacesUnquotedCidAttribute();
void namespacesCaseInsensitiveAttributeName();
void namespacesCidInBackgroundAttribute();
void namespacesCidInInlineStyleUrl();
void namespacesCidInStyleBlock();
void namespacesMultipleCidRefsOnOneLine();
void namespacesWhitespaceAroundEquals();
};
void TestHtmlBuilder::escapesPlainText()
{
ParsedMessage msg;
msg.ok = true;
msg.plainBody = QStringLiteral("a < b & c > d");
const QString html = HtmlBuilder::build(msg, HtmlBuilder::ForcePlain);
QVERIFY(html.contains(QStringLiteral("a < b & c > d")));
}
void TestHtmlBuilder::preservesHtmlBodyWhenHtmlRequested()
{
ParsedMessage msg;
msg.ok = true;
msg.htmlBody = QStringLiteral("hello
");
const QString html = HtmlBuilder::build(msg, HtmlBuilder::PreferHtml);
QVERIFY(html.contains(QStringLiteral("hello
")));
}
void TestHtmlBuilder::marksQuotedLines()
{
ParsedMessage msg;
msg.ok = true;
msg.plainBody = QStringLiteral("reply\n> quoted\nend");
const QString html = HtmlBuilder::build(msg, HtmlBuilder::ForcePlain);
QVERIFY(html.contains(QStringLiteral("class=\"quote\"")));
}
void TestHtmlBuilder::plainTextScriptTagIsNeutralised()
{
ParsedMessage msg;
msg.ok = true;
msg.plainBody = QStringLiteral("");
const QString html = HtmlBuilder::build(msg, HtmlBuilder::ForcePlain);
// Escaped, not embedded. (JavaScript is also disabled at the profile level,
// so this is the second of two independent defences.)
QVERIFY(!html.contains(QStringLiteral("