diff --git a/kmail/editorconvertertextplugins/markdown/markdownlib/markdownenginepage.cpp b/kmail/editorconvertertextplugins/markdown/markdownlib/markdownenginepage.cpp index a9ca2900..0b551cb9 100644 --- a/kmail/editorconvertertextplugins/markdown/markdownlib/markdownenginepage.cpp +++ b/kmail/editorconvertertextplugins/markdown/markdownlib/markdownenginepage.cpp @@ -1,70 +1,70 @@ /* Copyright (C) 2018-2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "markdownenginepage.h" #include #include #include MarkdownEnginePage::MarkdownEnginePage(QObject *parent) : QWebEnginePage(parent) { settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false); settings()->setAttribute(QWebEngineSettings::PluginsEnabled, false); settings()->setAttribute(QWebEngineSettings::AutoLoadImages, true); settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false); settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, false); settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, false); settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, false); settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, false); - settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, false); + //settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, false); settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, false); settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false); settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false); settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, false); settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false); settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false); settings()->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, false); settings()->setAttribute(QWebEngineSettings::ShowScrollBars, true); settings()->setAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript, false); settings()->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false); settings()->setAttribute(QWebEngineSettings::JavascriptCanPaste, false); settings()->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, false); #if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 13, 0) settings()->setAttribute(QWebEngineSettings::PdfViewerEnabled, false); #endif profile()->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies); } MarkdownEnginePage::~MarkdownEnginePage() { } bool MarkdownEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) { Q_UNUSED(type); Q_UNUSED(isMainFrame); if (url.scheme() == QLatin1String("data")) { return true; } return false; } diff --git a/kmail/editorconvertertextplugins/markdown/markdownlib/markdownpreviewwidget.cpp b/kmail/editorconvertertextplugins/markdown/markdownlib/markdownpreviewwidget.cpp index c094c35b..4f9c2e55 100644 --- a/kmail/editorconvertertextplugins/markdown/markdownlib/markdownpreviewwidget.cpp +++ b/kmail/editorconvertertextplugins/markdown/markdownlib/markdownpreviewwidget.cpp @@ -1,103 +1,103 @@ /* Copyright (C) 2018-2020 Laurent Montel This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "markdownpreviewwidget.h" #include "markdownconverter.h" #include "markdownenginepage.h" #include #include #include #include #include #include #include MarkdownPreviewWidget::MarkdownPreviewWidget(QWidget *parent) : QWidget(parent) { mConverter = new MarkdownConverter(this); mConverter->setObjectName(QStringLiteral("converter")); connect(mConverter, &MarkdownConverter::failed, this, &MarkdownPreviewWidget::converterFailed); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setObjectName(QStringLiteral("mainLayout")); mainLayout->setContentsMargins(0, 0, 0, 0); MarkdownEnginePage *page = new MarkdownEnginePage(this); mWebView = new QWebEngineView(this); mWebView->setPage(page); mWebView->resize(600, 800); mWebView->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false); mWebView->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, false); mWebView->settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false); mWebView->settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, false); mWebView->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, false); mWebView->settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, false); mWebView->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, false); - mWebView->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, false); + //mWebView->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, false); mWebView->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); mWebView->settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, false); mWebView->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, false); mWebView->settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false); mWebView->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false); mWebView->settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, false); mWebView->settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false); mWebView->setObjectName(QStringLiteral("webengine")); mainLayout->addWidget(mWebView); mHoverUrlLabel = new QLabel(this); mHoverUrlLabel->setObjectName(QStringLiteral("mHoverUrlLabel")); mainLayout->addWidget(mHoverUrlLabel); mWebView->setContextMenuPolicy(Qt::NoContextMenu); connect(page, &MarkdownEnginePage::linkHovered, this, &MarkdownPreviewWidget::slotLinkHovered); } MarkdownPreviewWidget::~MarkdownPreviewWidget() { } void MarkdownPreviewWidget::slotLinkHovered(const QString &url) { QString truncateUrl = url; if (truncateUrl.length() > 80) { truncateUrl.truncate(80); truncateUrl += QStringLiteral("..."); } mHoverUrlLabel->setText(truncateUrl); mHoverUrlLabel->setToolTip(url); } void MarkdownPreviewWidget::converterFailed(const QString &msg) { KMessageBox::error(this, i18n("Converter Error"), msg); } void MarkdownPreviewWidget::setConverterSettings(bool enableEmbeddedLabel, bool enableExtraDefinitionLists) { mConverter->setEnableEmbeddedLabel(enableEmbeddedLabel); mConverter->setEnableExtraDefinitionLists(enableExtraDefinitionLists); } void MarkdownPreviewWidget::slotUpdatePreview(const QString &text) { mWebView->setHtml(mConverter->convertTextToMarkdown(text), QUrl(QStringLiteral("file://"))); }