From fb57031a8d81a19e426765b1ceaa325ce51411b4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 5 Nov 2012 18:51:31 +0100 Subject: adblock work readded an icon in the urlbar when adblock is active, BUT with different features: you can now disable adblock "per-site", in a similar way chromium does. cleaned up adblock manager code, removing some old no more used code fragments --- src/adblock/adblockhostmatcher.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src/adblock/adblockhostmatcher.cpp') diff --git a/src/adblock/adblockhostmatcher.cpp b/src/adblock/adblockhostmatcher.cpp index 021fe12d..5033c6f7 100644 --- a/src/adblock/adblockhostmatcher.cpp +++ b/src/adblock/adblockhostmatcher.cpp @@ -29,11 +29,11 @@ // Rekonq Includes #include "rekonq_defines.h" + bool AdBlockHostMatcher::tryAddFilter(const QString &filter) { if (filter.startsWith(QL1S("||"))) { - QString domain = filter.mid(2); if (!domain.endsWith(QL1C('^'))) @@ -49,8 +49,41 @@ bool AdBlockHostMatcher::tryAddFilter(const QString &filter) domain = domain.toLower(); m_hostList.insert(domain); - m_hostList.insert(QL1S("www.") + domain); return true; } + + if (filter.startsWith(QL1S("@@"))) + { + QString domain = filter.mid(2); + + if (domain.contains(QL1C('^'))) + return false; + + if (domain.contains(QL1C('$'))) + return false; + + if (domain.contains(QL1C('*'))) + return false; + + if (domain.contains(QL1C('|'))) + return false; + + if (domain.contains(QL1C('/'))) + { + if (!domain.endsWith(QL1C('/'))) + return false; + } + domain = domain.toLower(); + m_hostList.insert(domain); + return true; + } + return false; } + + +void AdBlockHostMatcher::remove(const QString &hostRule) +{ + bool on = m_hostList.remove(hostRule); + kDebug() << "REMOVED? " << on; +} -- cgit v1.2.1