summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-29 15:31:14 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-29 15:32:12 (GMT)
commit111feeb5c1c144e89d345eb5789445d2a1d9f041 (patch)
tree49266f9e32a7e62ba95684ac282fe5daba111e03
parent85ebc5a815f7080e95d297df0b262b55351df8d5 (diff)
Remove script from mail directly
-rw-r--r--messageviewer/src/htmlwriter/webengineparthtmlwriter.cpp8
-rw-r--r--messageviewer/src/htmlwriter/webengineparthtmlwriter.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/messageviewer/src/htmlwriter/webengineparthtmlwriter.cpp b/messageviewer/src/htmlwriter/webengineparthtmlwriter.cpp
index 21eb7cc..a01d0fa 100644
--- a/messageviewer/src/htmlwriter/webengineparthtmlwriter.cpp
+++ b/messageviewer/src/htmlwriter/webengineparthtmlwriter.cpp
@@ -24,6 +24,7 @@
#include <cassert>
#include <QByteArray>
+#include <QRegularExpression>
using namespace MessageViewer;
@@ -60,6 +61,7 @@ void WebEnginePartHtmlWriter::end()
insertExtraHead();
mExtraHead.clear();
}
+ removeJscripts();
mHtmlView->setHtml(mHtml, QUrl(QStringLiteral("file:///")));
mHtmlView->show();
mHtml.clear();
@@ -70,6 +72,12 @@ void WebEnginePartHtmlWriter::end()
Q_EMIT finished();
}
+void WebEnginePartHtmlWriter::removeJscripts()
+{
+ const QRegularExpression reg(QStringLiteral("<script>.*</script>"));
+ mHtml.remove(reg);
+}
+
void WebEnginePartHtmlWriter::reset()
{
if (mState != Ended) {
diff --git a/messageviewer/src/htmlwriter/webengineparthtmlwriter.h b/messageviewer/src/htmlwriter/webengineparthtmlwriter.h
index 69c68b0..81bd8ca 100644
--- a/messageviewer/src/htmlwriter/webengineparthtmlwriter.h
+++ b/messageviewer/src/htmlwriter/webengineparthtmlwriter.h
@@ -54,6 +54,7 @@ private:
void insertExtraHead();
private:
+ void removeJscripts();
MailWebEngineView *mHtmlView;
QString mHtml;
QString mExtraHead;