summaryrefslogtreecommitdiff
path: root/src/adblock/adblockmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/adblock/adblockmanager.cpp')
-rw-r--r--src/adblock/adblockmanager.cpp53
1 files changed, 8 insertions, 45 deletions
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);