From aadae5dd9efdd2c33bb80871d0cde168b3c7e211 Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Mon, 27 Mar 2023 00:50:16 +0200 Subject: [PATCH] AdBlock: Workaround for "Blocked content" page - QtWebEngine blocks redirection to "data:" urls. - Includes light / dark style Signed-off-by: Juraj Oravec --- CHANGELOG | 1 + src/lib/adblock/adblockurlinterceptor.cpp | 15 +++++------ src/lib/adblock/data/adblock.html | 32 ++++++++++++++++++----- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 844cc3a58..97b36e0f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ Version 23.04.0 * PyFalkon: addBookmark - make C++ own parameters (fixes potential crash) * KWallet: Store passwords in a map format * History: Don't delete all items under dates when filtering + * AdBlock: Workaround for "Blocked content" page Version 22.08.2 * Fix: Typing text in the search bar sends data although suggestions are disabled (by Juraj Oravec) (BUG: 439268) diff --git a/src/lib/adblock/adblockurlinterceptor.cpp b/src/lib/adblock/adblockurlinterceptor.cpp index 55c1f4c37..428645c21 100644 --- a/src/lib/adblock/adblockurlinterceptor.cpp +++ b/src/lib/adblock/adblockurlinterceptor.cpp @@ -37,14 +37,13 @@ void AdBlockUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &request) } if (request.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) { - QString page; - page.append(QzTools::readAllFileContents(QSL(":adblock/data/adblock.html"))); - page.replace(QSL("%FAVICON%"), QSL("qrc:adblock/data/adblock_big.png")); - page.replace(QSL("%IMAGE%"), QSL("qrc:adblock/data/adblock_big.png")); - page.replace(QSL("%TITLE%"), tr("Blocked content")); - page.replace(QSL("%RULE%"), tr("Blocked by %1 (%2)").arg(ruleFilter, ruleSubscription)); - page = QzTools::applyDirectionToPage(page); - request.redirect(QUrl(QString::fromUtf8(QByteArray("data:text/html;base64,") + page.toUtf8().toBase64()))); + QString url = QSL("qrc:adblock/data/adblock.html?direction=%DIRECTION%&title=%1&rule=%3").arg( + tr("Blocked content"), + tr("Blocked by %1 (%2)").arg(ruleFilter, ruleSubscription) + ); + url = QzTools::applyDirectionToPage(url); + + request.redirect(QUrl(url)); } else { request.block(true); } diff --git a/src/lib/adblock/data/adblock.html b/src/lib/adblock/data/adblock.html index 64921af61..fe72aef9b 100644 --- a/src/lib/adblock/data/adblock.html +++ b/src/lib/adblock/data/adblock.html @@ -1,18 +1,36 @@ -%TITLE% - +Blocked content +
- +

AdBlock

- %RULE% +
+ +