diff --git a/messageviewer/src/viewer/webengine/blockexternalresourcesurlinterceptor/blockexternalresourcesurlinterceptor.cpp b/messageviewer/src/viewer/webengine/blockexternalresourcesurlinterceptor/blockexternalresourcesurlinterceptor.cpp index acff59df..61d4a745 100644 --- a/messageviewer/src/viewer/webengine/blockexternalresourcesurlinterceptor/blockexternalresourcesurlinterceptor.cpp +++ b/messageviewer/src/viewer/webengine/blockexternalresourcesurlinterceptor/blockexternalresourcesurlinterceptor.cpp @@ -1,64 +1,67 @@ /* Copyright (C) 2016-2017 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 "blockexternalresourcesurlinterceptor.h" #include using namespace MessageViewer; BlockExternalResourcesUrlInterceptor::BlockExternalResourcesUrlInterceptor(QObject *parent) : WebEngineViewer::NetworkPluginUrlInterceptorInterface(parent) { } BlockExternalResourcesUrlInterceptor::~BlockExternalResourcesUrlInterceptor() { } bool BlockExternalResourcesUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) { + if (info.requestUrl().scheme() == QStringLiteral("data") + || info.requestUrl().scheme() == QStringLiteral("file")) + return false; const QWebEngineUrlRequestInfo::ResourceType resourceType = info.resourceType(); const QWebEngineUrlRequestInfo::NavigationType navigationType = info.navigationType(); if (resourceType == QWebEngineUrlRequestInfo::ResourceTypeMedia || resourceType == QWebEngineUrlRequestInfo::ResourceTypePing || resourceType == QWebEngineUrlRequestInfo::ResourceTypePrefetch || resourceType == QWebEngineUrlRequestInfo::ResourceTypeFavicon || resourceType == QWebEngineUrlRequestInfo::ResourceTypeXhr || resourceType == QWebEngineUrlRequestInfo::ResourceTypeObject || resourceType == QWebEngineUrlRequestInfo::ResourceTypeScript || resourceType == QWebEngineUrlRequestInfo::ResourceTypeServiceWorker || resourceType == QWebEngineUrlRequestInfo::ResourceTypeSharedWorker || resourceType == QWebEngineUrlRequestInfo::ResourceTypeWorker || resourceType == QWebEngineUrlRequestInfo::ResourceTypeSubResource || resourceType == QWebEngineUrlRequestInfo::ResourceTypePluginResource || resourceType == QWebEngineUrlRequestInfo::ResourceTypeCspReport || resourceType == QWebEngineUrlRequestInfo::ResourceTypeUnknown) { return true; } else if (navigationType == QWebEngineUrlRequestInfo::NavigationTypeFormSubmitted) { Q_EMIT formSubmittedForbidden(); return true; } else if (navigationType == QWebEngineUrlRequestInfo::NavigationTypeReload || navigationType == QWebEngineUrlRequestInfo::NavigationTypeTyped || navigationType == QWebEngineUrlRequestInfo::NavigationTypeBackForward || navigationType == QWebEngineUrlRequestInfo::NavigationTypeOther) { return true; } return false; } diff --git a/messageviewer/src/viewer/webengine/blockexternalresourcesurlinterceptor/loadexternalreferencesurlinterceptor.cpp b/messageviewer/src/viewer/webengine/blockexternalresourcesurlinterceptor/loadexternalreferencesurlinterceptor.cpp index 2ac7b0cc..8e56372a 100644 --- a/messageviewer/src/viewer/webengine/blockexternalresourcesurlinterceptor/loadexternalreferencesurlinterceptor.cpp +++ b/messageviewer/src/viewer/webengine/blockexternalresourcesurlinterceptor/loadexternalreferencesurlinterceptor.cpp @@ -1,72 +1,75 @@ /* Copyright (C) 2016 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 "loadexternalreferencesurlinterceptor.h" #include using namespace MessageViewer; class MessageViewer::LoadExternalReferencesUrlInterceptorPrivate { public: LoadExternalReferencesUrlInterceptorPrivate() : mAllowLoadExternalReference(false) { } bool mAllowLoadExternalReference; }; LoadExternalReferencesUrlInterceptor::LoadExternalReferencesUrlInterceptor(QObject *parent) : WebEngineViewer::NetworkPluginUrlInterceptorInterface(parent) , d(new LoadExternalReferencesUrlInterceptorPrivate) { } LoadExternalReferencesUrlInterceptor::~LoadExternalReferencesUrlInterceptor() { delete d; } bool LoadExternalReferencesUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) { + if (info.requestUrl().scheme() == QStringLiteral("data") + || info.requestUrl().scheme() == QStringLiteral("file")) + return false; if (d->mAllowLoadExternalReference) { return false; } else { if (info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeImage && !info.requestUrl().isLocalFile() && (info.requestUrl().scheme() != QLatin1String("cid"))) { return true; } else if (info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMedia) { return true; } } return false; } void LoadExternalReferencesUrlInterceptor::setAllowExternalContent(bool b) { d->mAllowLoadExternalReference = b; } bool LoadExternalReferencesUrlInterceptor::allowExternalContent() const { return d->mAllowLoadExternalReference; }