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