From: Soren Stoutner Date: Thu, 26 Jun 2025 19:08:49 +0000 (-0700) Subject: Block all CSP requests. https://redmine.stoutner.com/issues/1193 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=e08f12b1722ae343ed5b4fba616a6493ceb3738b;p=PrivacyBrowserPC.git Block all CSP requests. https://redmine.stoutner.com/issues/1193 --- diff --git a/src/interceptors/UrlRequestInterceptor.cpp b/src/interceptors/UrlRequestInterceptor.cpp index c35928b..b0b4029 100644 --- a/src/interceptors/UrlRequestInterceptor.cpp +++ b/src/interceptors/UrlRequestInterceptor.cpp @@ -60,7 +60,7 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques // Mark the request struct as blocked. requestStructPointer->dispositionInt = FilterListHelper::BLOCKED; - // Mark the prefetch request as blocked by the default behavior. + // Describe the prefetch request as blocked by the default behavior. requestStructPointer->filterListTitle = i18nc("Default prefetch blocking", "Default blocking of all prefetch requests."); // Set the continue processing flag. @@ -69,6 +69,23 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques break; } + case QWebEngineUrlRequestInfo::ResourceTypeCspReport: + { + // Block the request. + urlRequestInfo.block(true); + + // Mark the request struct as blocked. + requestStructPointer->dispositionInt = FilterListHelper::BLOCKED; + + // Describe the CSP request as blocked by the default behavior. + requestStructPointer->filterListTitle = i18nc("Default CSP blocking", "Default blocking of all CSP requests."); + + // Set the continue processing flag. + continueProcessing = false; + + break; + } + case QWebEngineUrlRequestInfo::ResourceTypeNavigationPreloadMainFrame: case QWebEngineUrlRequestInfo::ResourceTypeNavigationPreloadSubFrame: { @@ -78,7 +95,7 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques // Mark the request struct as blocked. requestStructPointer->dispositionInt = FilterListHelper::BLOCKED; - // Mark the preload request as blocked by the default behavior. + // Describe the preload request as blocked by the default behavior. requestStructPointer->filterListTitle = i18nc("Default preload blocking", "Default blocking of all preload requests."); // Set the continue processing flag. @@ -112,7 +129,7 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques // Mark the request struct as blocked. requestStructPointer->dispositionInt = FilterListHelper::BLOCKED; - // Mark the ping as blocked by the default behavior. + // Describe the ping as blocked by the default behavior. requestStructPointer->filterListTitle = i18nc("Default HTTP ping blocking", "Default blocking of all HTTP ping requests."); // Set the continue processing flag.