diff options
Diffstat (limited to 'src/adblock')
-rw-r--r-- | src/adblock/adblockhostmatcher.cpp | 7 | ||||
-rw-r--r-- | src/adblock/adblockhostmatcher.h | 2 | ||||
-rw-r--r-- | src/adblock/adblockmanager.cpp | 53 | ||||
-rw-r--r-- | src/adblock/adblockmanager.h | 1 |
4 files changed, 8 insertions, 55 deletions
diff --git a/src/adblock/adblockhostmatcher.cpp b/src/adblock/adblockhostmatcher.cpp index 5033c6f7..60936ec0 100644 --- a/src/adblock/adblockhostmatcher.cpp +++ b/src/adblock/adblockhostmatcher.cpp @@ -80,10 +80,3 @@ bool AdBlockHostMatcher::tryAddFilter(const QString &filter) return false; } - - -void AdBlockHostMatcher::remove(const QString &hostRule) -{ - bool on = m_hostList.remove(hostRule); - kDebug() << "REMOVED? " << on; -} diff --git a/src/adblock/adblockhostmatcher.h b/src/adblock/adblockhostmatcher.h index 3ce6e284..79918239 100644 --- a/src/adblock/adblockhostmatcher.h +++ b/src/adblock/adblockhostmatcher.h @@ -48,8 +48,6 @@ public: { m_hostList.clear(); } - - void remove(const QString &hostRule); private: QSet<QString> m_hostList; diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index 49dfa4f4..d5a3e27c 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -241,6 +241,14 @@ bool AdBlockManager::blockRequest(const QNetworkRequest &request) if (request.url().scheme() != QL1S("http")) return false; + QStringList whiteRefererList = ReKonfig::whiteReferer(); + const QString referer = request.rawHeader("referer"); + Q_FOREACH(const QString &host, whiteRefererList) + { + if (referer.contains(host)) + return false; + } + QString urlString = request.url().toString(); // We compute a lowercase version of the URL so each rule does not // have to do it. @@ -368,51 +376,6 @@ void AdBlockManager::addCustomRule(const QString &stringRule, bool reloadPage) } -void AdBlockManager::removeCustomHostRule(const QString &stringRule, bool reloadPage) -{ - // save rule in local filters - QString localRulesFilePath = KStandardDirs::locateLocal("appdata" , QL1S("adblockrules_local")); - - QFile ruleFile(localRulesFilePath); - if (!ruleFile.open(QFile::ReadOnly)) - { - kDebug() << "Unable to open rule file" << localRulesFilePath; - return; - } - - QTextStream in(&ruleFile); - QStringList localRules; - QString r; - do - { - r = in.readLine(); - if (r != stringRule) - localRules << r; - } - while (!r.isNull()); - ruleFile.close(); - - if (!ruleFile.open(QFile::WriteOnly)) - { - kDebug() << "Unable to open rule file" << localRulesFilePath; - return; - } - - QTextStream out(&ruleFile); - Q_FOREACH(const QString &r, localRules) - { - out << r << '\n'; - } - - // (un)load it - _hostWhiteList.remove(stringRule); - - // eventually reload page - if (reloadPage) - emit reloadCurrentPage(); -} - - bool AdBlockManager::isAdblockEnabledForHost(const QString &host) { return ! _hostWhiteList.match(host); diff --git a/src/adblock/adblockmanager.h b/src/adblock/adblockmanager.h index 7e93a379..993fa9a7 100644 --- a/src/adblock/adblockmanager.h +++ b/src/adblock/adblockmanager.h @@ -165,7 +165,6 @@ public: bool blockRequest(const QNetworkRequest &request); void addCustomRule(const QString &, bool reloadPage = true); - void removeCustomHostRule(const QString &, bool reloadPage = true); bool isAdblockEnabledForHost(const QString &host); |