Commit 44b0e3e6 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix block url

parent 8047f9f9
Pipeline #53826 canceled with stage
......@@ -61,6 +61,25 @@ bool RemoteContentManager::isAutorized(const QUrl &url, bool &contains) const
return false;
}
bool RemoteContentManager::isBlocked(const QUrl &url, bool &contains) const
{
const QString host = url.host();
const QString urlToString = url.toString();
contains = false;
for (const RemoteContentInfo &info : qAsConst(mRemoveContentInfo)) {
if (info.url() == urlToString) {
contains = true;
return info.status() == RemoteContentInfo::RemoteContentInfoStatus::Blocked;
} else if (info.url() == host) {
contains = true;
return info.status() == RemoteContentInfo::RemoteContentInfoStatus::Blocked;
}
}
return false;
}
void RemoteContentManager::loadSettings()
{
mRemoveContentInfo.clear();
......
......@@ -32,6 +32,8 @@ public:
Q_REQUIRED_RESULT bool isUnique(const RemoteContentInfo &newInfo) const;
Q_REQUIRED_RESULT bool isBlocked(const QUrl &url, bool &contains) const;
private:
void loadSettings();
void writeSettings();
......
......@@ -27,6 +27,13 @@ bool LoadExternalReferencesUrlInterceptor::interceptRequest(QWebEngineUrlRequest
return false;
}
if (mAllowLoadExternalReference) {
if (info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeImage && !info.requestUrl().isLocalFile() && (scheme != QLatin1String("cid"))) {
const QUrl url = info.requestUrl().adjusted(QUrl::RemovePath | QUrl::RemovePort | QUrl::RemoveQuery);
bool contains = false;
if (MessageViewer::RemoteContentManager::self()->isBlocked(url, contains)) {
return true;
}
}
return false;
} else {
if (info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeImage && !info.requestUrl().isLocalFile() && (scheme != QLatin1String("cid"))) {
......
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