Commit 258f67d5 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Merge remote-tracking branch 'origin/release/20.04'

parents 65cce9e3 605ab089
Pipeline #24307 passed with stage
in 62 minutes and 40 seconds
......@@ -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()
......
......@@ -635,15 +635,6 @@ bool Util::saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *
return saveMessageInMboxAndGetUrl(url, retrievedMsgs, parent, appendMessages);
}
bool Util::excludeExtraHeader(const QString &s)
{
QRegularExpression ref(QStringLiteral("http-equiv=\\s*(\'|\")(&#82;|R)EFRESH(\'|\")"), QRegularExpression::CaseInsensitiveOption);
if (s.contains(ref)) {
return true;
}
return false;
}
QAction *Util::createAppAction(const KService::Ptr &service, bool singleOffer, QActionGroup *actionGroup, QObject *parent)
{
QString actionName(service->name().replace(QLatin1Char('&'), QStringLiteral("&&")));
......@@ -661,6 +652,19 @@ QAction *Util::createAppAction(const KService::Ptr &service, bool singleOffer, Q
return act;
}
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;
}
void Util::addHelpTextAction(QAction *act, const QString &text)
{
act->setStatusTip(text);
......@@ -750,13 +754,9 @@ Util::HtmlMessageInfo Util::processHtml(const QString &htmlSource)
}
const int index = startIndex + 6;
messageInfo.extraHead = s.mid(index, endIndex - index);
#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.
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