Commit b458546b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Prepare to use it in akregator

parent def911b0
Pipeline #55540 canceled with stage
......@@ -28,24 +28,12 @@ bool LoadExternalReferencesUrlInterceptor::interceptRequest(QWebEngineUrlRequest
}
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 urlIsBlocked(info.requestUrl());
}
return false;
} else {
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()->isAutorized(url, contains)) {
return false;
}
if (!contains) {
Q_EMIT urlBlocked(info.requestUrl());
}
return true;
return urlAuthorized(info.requestUrl());
} else if (info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeFontResource) {
return true;
} else if (info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeStylesheet) {
......@@ -55,6 +43,29 @@ bool LoadExternalReferencesUrlInterceptor::interceptRequest(QWebEngineUrlRequest
return false;
}
bool LoadExternalReferencesUrlInterceptor::urlIsBlocked(const QUrl &requestedUrl)
{
const QUrl url = requestedUrl.adjusted(QUrl::RemovePath | QUrl::RemovePort | QUrl::RemoveQuery);
bool contains = false;
if (MessageViewer::RemoteContentManager::self()->isBlocked(url, contains)) {
return true;
}
return false;
}
bool LoadExternalReferencesUrlInterceptor::urlAuthorized(const QUrl &requestedUrl)
{
const QUrl url = requestedUrl.adjusted(QUrl::RemovePath | QUrl::RemovePort | QUrl::RemoveQuery);
bool contains = false;
if (MessageViewer::RemoteContentManager::self()->isAutorized(url, contains)) {
return false;
}
if (!contains) {
Q_EMIT urlBlocked(requestedUrl);
}
return true;
}
void LoadExternalReferencesUrlInterceptor::setAllowExternalContent(bool b)
{
mAllowLoadExternalReference = b;
......
......@@ -23,6 +23,10 @@ public:
Q_SIGNALS:
void urlBlocked(const QUrl &url);
protected:
Q_REQUIRED_RESULT bool urlAuthorized(const QUrl &requestedUrl);
Q_REQUIRED_RESULT bool urlIsBlocked(const QUrl &requestedUrl);
private:
bool mAllowLoadExternalReference = false;
};
......
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