summaryrefslogtreecommitdiff
path: root/src/adblock/adblockmanager.cpp
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2010-08-21 21:40:59 +0200
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-08-22 00:50:13 +0200
commit12f8323ae8e5e469fb0b662f29bd8fedadb85faa (patch)
tree61a394d0911239e02fbd495cd171e8594fd833b8 /src/adblock/adblockmanager.cpp
parentRestore bk icon on the right (diff)
downloadrekonq-12f8323ae8e5e469fb0b662f29bd8fedadb85faa.tar.xz
Add support for domain option in the ad block module
Some ads were not filtered because they were incorrectly matched by the whitelist. This is because we ignore options, including the domain restrictions. For example, the white filter: @@||pagead2.googlesyndication.com/pagead/show_ads.js$domain=kde.org would match any page regardless of the domain restriction. So no ads from pagead2.googlesyndication.com were filtered. This patch adds support for "domain" options in the fallback rules (the other AdBlockRuleImpl rejects options). The domain of the frame making the request is now compared to the option to take the right decision. This patch requires Qt 4.7 with a recent QtWebKit 2.0.
Diffstat (limited to 'src/adblock/adblockmanager.cpp')
-rw-r--r--src/adblock/adblockmanager.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp
index 8deb0bcd..f7c61cdb 100644
--- a/src/adblock/adblockmanager.cpp
+++ b/src/adblock/adblockmanager.cpp
@@ -187,7 +187,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa
foreach(const AdBlockRule &filter, _whiteList)
{
- if (filter.match(urlString, urlStringLowerCase))
+ if (filter.match(request, urlString, urlStringLowerCase))
{
kDebug() << "****ADBLOCK: WHITE RULE (@@) Matched: ***********";
kDebug() << "UrlString: " << urlString;
@@ -205,7 +205,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa
foreach(const AdBlockRule &filter, _blackList)
{
- if (filter.match(urlString, urlStringLowerCase))
+ if (filter.match(request, urlString, urlStringLowerCase))
{
kDebug() << "****ADBLOCK: BLACK RULE Matched: ***********";
kDebug() << "UrlString: " << urlString;
@@ -215,7 +215,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa
foreach(QWebElement el, elements)
{
const QString srcAttribute = el.attribute("src");
- if (filter.match(srcAttribute, srcAttribute.toLower()))
+ if (filter.match(request, srcAttribute, srcAttribute.toLower()))
{
kDebug() << "MATCHES ATTRIBUTE!!!!!";
el.setStyleProperty(QL1S("visibility"), QL1S("hidden"));