Commit 605ab089 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

We don't need to add all testcase when we use qt >= 5.14

parent 33753beb
......@@ -18,6 +18,7 @@
#include "messageviewerutilstest.h"
#include "utils/messageviewerutil.h"
#include <QTest>
#include <qtwebenginewidgetsversion.h>
QTEST_GUILESS_MAIN(MessageViewerUtilsTest)
MessageViewerUtilsTest::MessageViewerUtilsTest(QObject *parent)
......@@ -30,12 +31,14 @@ void MessageViewerUtilsTest::shouldExcludeHeader_data()
QTest::addColumn<QString>("header");
QTest::addColumn<bool>("exclude");
QTest::newRow("emptylist") << QString() << false;
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 14, 0)
QTest::newRow("REFRESH1") << QStringLiteral("<meta content=\"0;URL=http://www.kde.org\" http-equiv=\'REFRESH\'></head>") << true;
QTest::newRow("REFRESH2") << QStringLiteral("<meta content=\"0;URL=http://www.kde.org\" http-equiv=\"REFRESH\"></head>") << true;
QTest::newRow("REFRESH3") << QStringLiteral("<meta content=\"0;URL=http://www.kde.org\" http-equiv=\"refresh\"></head>") << true;
QTest::newRow("REFRESH4") << QStringLiteral("<meta content=\"0;URL=http://www.kde.org\" http-equiv=\"&#82;EFRESH\"></head>") << true;
QTest::newRow("REFRESH5") << QStringLiteral("<meta content=\"0;URL=http://www.kde.org\" http-equiv=\'&#82;EFRESH\'></head>") << true;
QTest::newRow("REFRESH6") << QStringLiteral("<meta content=\"0;URL=http://www.kde.org\" http-equiv= \"REFRESH\"></head>") << true;
#endif
}
void MessageViewerUtilsTest::shouldExcludeHeader()
......
......@@ -661,10 +661,14 @@ QAction *Util::createAppAction(const KService::Ptr &service, bool singleOffer, Q
bool Util::excludeExtraHeader(const QString &s)
{
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 14, 0)
//Remove this hack with https://codereview.qt-project.org/#/c/256100/2 is merged
//Don't authorize to refresh content.
QRegularExpression ref(QStringLiteral("http-equiv=\\s*(\'|\")(&#82;|R)EFRESH(\'|\")"), QRegularExpression::CaseInsensitiveOption);
if (s.contains(ref)) {
return true;
}
#endif
return false;
}
......@@ -721,14 +725,11 @@ Util::HtmlMessageInfo Util::processHtml(const QString &htmlSource)
messageInfo.htmlSource = htmlSource;
return messageInfo;
}
messageInfo.extraHead = s.mid(startIndex + 6, endIndex - startIndex - 6);
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 14, 0)
//Remove this hack with https://codereview.qt-project.org/#/c/256100/2 is merged
//Don't authorize to refresh content.
const int index = startIndex + 6;
messageInfo.extraHead = s.mid(index, endIndex - index);
if (MessageViewer::Util::excludeExtraHeader(s)) {
messageInfo.extraHead.clear();
}
#endif
s = s.remove(startIndex, endIndex - startIndex + 7).trimmed();
}
// body
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment