[pim/kdepim-addons] plugins/webengineurlinterceptor/adblock: Fix intercept url

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 67f6d4372c5dda648971a7806549d60c72cd1215 by Laurent Montel.
Committed on 15/08/2026 at 10:23.
Pushed by mlaurent into branch 'master'.

Fix intercept url

M  +10   -4    plugins/webengineurlinterceptor/adblock/adblockmanager.cpp

https://invent.kde.org/pim/kdepim-addons/-/commit/67f6d4372c5dda648971a7806549d60c72cd1215

diff --git a/plugins/webengineurlinterceptor/adblock/adblockmanager.cpp b/plugins/webengineurlinterceptor/adblock/adblockmanager.cpp
index 75242c34a..2ca2f2074 100644
--- a/plugins/webengineurlinterceptor/adblock/adblockmanager.cpp
+++ b/plugins/webengineurlinterceptor/adblock/adblockmanager.cpp
@@ -267,14 +267,20 @@ bool AdblockManager::interceptRequest(QWebEngineUrlRequestInfo &info)
 
     const auto &redirect = result.redirect;
     const auto &rewrittenUrl = result.rewrittenUrl;
+    // Returning true tells the caller to block the request, so only report it for
+    // requests we really want to block: a redirected request must go through.
     if (!redirect.empty()) {
         info.redirect(QUrl(QString::fromStdString(std::string(redirect))));
-    } else if (result.matched) {
-        info.block(result.matched);
-    } else if (!rewrittenUrl.empty()) {
+        return false;
+    }
+    if (result.matched) {
+        info.block(true);
+        return true;
+    }
+    if (!rewrittenUrl.empty()) {
         info.redirect(QUrl(QString::fromStdString(std::string(rewrittenUrl))));
     }
-    return true;
+    return false;
 }
 
 void q_cdebug_adblock(const char *message)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.