summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2013-02-21 17:06:25 +0100
committerAndrea Diamantini <adjam7@gmail.com>2013-02-21 17:06:25 +0100
commitd57c29564826da0c7f668d7f1b8524bddef9bc6b (patch)
tree82aeb42a1b48cf26e398c00db608df3b39a3fffc /src
parentAdd overwrite flag to file copy ad filters list to not bother users (diff)
downloadrekonq-d57c29564826da0c7f668d7f1b8524bddef9bc6b.tar.xz
Triple check against stupid rules like "*" or "##"
CCBUG: 315002
Diffstat (limited to 'src')
-rw-r--r--src/adblock/adblockmanager.cpp9
-rw-r--r--src/adblock/adblockrule.cpp2
-rw-r--r--src/adblock/adblockruletextmatchimpl.cpp4
-rw-r--r--src/adblock/adblockruletextmatchimpl.h1
4 files changed, 14 insertions, 2 deletions
diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp
index 4b603b8c..fe4d028a 100644
--- a/src/adblock/adblockmanager.cpp
+++ b/src/adblock/adblockmanager.cpp
@@ -208,6 +208,9 @@ void AdBlockManager::loadRuleString(const QString &stringRule)
return;
const QString filter = stringRule.mid(2);
+ if (filter.isEmpty())
+ return;
+
AdBlockRule rule(filter);
_whiteList << rule;
return;
@@ -216,7 +219,11 @@ void AdBlockManager::loadRuleString(const QString &stringRule)
// hide (CSS) rules
if (stringRule.startsWith(QL1S("##")))
{
- _hideList << stringRule.mid(2);
+ const QString filter = stringRule.mid(2);
+ if (filter.isEmpty())
+ return;
+
+ _hideList << filter;
return;
}
diff --git a/src/adblock/adblockrule.cpp b/src/adblock/adblockrule.cpp
index d65c340d..01a8e420 100644
--- a/src/adblock/adblockrule.cpp
+++ b/src/adblock/adblockrule.cpp
@@ -59,7 +59,7 @@ RuleTypes AdBlockRule::ruleType(const QString &filter)
{
if (AdBlockRuleTextMatchImpl::isTextMatchFilter(filter))
return TextRule;
-
+
if (AdBlockRuleNullImpl::isNullFilter(filter))
return NullRule;
diff --git a/src/adblock/adblockruletextmatchimpl.cpp b/src/adblock/adblockruletextmatchimpl.cpp
index fd901e9c..1938cb92 100644
--- a/src/adblock/adblockruletextmatchimpl.cpp
+++ b/src/adblock/adblockruletextmatchimpl.cpp
@@ -3,6 +3,7 @@
* This file is a part of the rekonq project
*
* Copyright (C) 2010-2011 by Benjamin Poulain <ikipou at gmail dot com>
+* Copyright (C) 2010-2013 by Andrea Diamantini <adjam7 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or
@@ -48,6 +49,9 @@ bool AdBlockRuleTextMatchImpl::match(const QNetworkRequest &request, const QStri
{
Q_UNUSED(request);
Q_UNUSED(encodedUrl);
+ if (m_textToMatch.isEmpty())
+ return false;
+
// Case sensitive compare is faster, but would be incorrect with encodedUrl since
// we do want case insensitive.
// What we do is work on a lowercase version of m_textToMatch, and compare to the lowercase
diff --git a/src/adblock/adblockruletextmatchimpl.h b/src/adblock/adblockruletextmatchimpl.h
index 7a99f41d..8c1b1363 100644
--- a/src/adblock/adblockruletextmatchimpl.h
+++ b/src/adblock/adblockruletextmatchimpl.h
@@ -3,6 +3,7 @@
* This file is a part of the rekonq project
*
* Copyright (C) 2010-2011 by Benjamin Poulain <ikipou at gmail dot com>
+* Copyright (C) 2010-2013 by Andrea Diamantini <adjam7 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or