summaryrefslogtreecommitdiff
path: root/src/adblock/adblockrulefallbackimpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/adblock/adblockrulefallbackimpl.cpp')
-rw-r--r--src/adblock/adblockrulefallbackimpl.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/adblock/adblockrulefallbackimpl.cpp b/src/adblock/adblockrulefallbackimpl.cpp
index dfe732df..915516c7 100644
--- a/src/adblock/adblockrulefallbackimpl.cpp
+++ b/src/adblock/adblockrulefallbackimpl.cpp
@@ -41,7 +41,7 @@ static inline bool isRegExpFilter(const QString &filter)
}
AdBlockRuleFallbackImpl::AdBlockRuleFallbackImpl(const QString &filter)
- : AdBlockRuleImpl(filter)
+ : AdBlockRuleImpl(filter)
{
m_regExp.setCaseSensitivity(Qt::CaseInsensitive);
m_regExp.setPatternSyntax(QRegExp::RegExp2);
@@ -49,19 +49,23 @@ AdBlockRuleFallbackImpl::AdBlockRuleFallbackImpl(const QString &filter)
QString parsedLine = filter;
const int optionsNumber = parsedLine.lastIndexOf(QL1C('$'));
- if (optionsNumber >= 0 && !isRegExpFilter(parsedLine)) {
+ if (optionsNumber >= 0 && !isRegExpFilter(parsedLine))
+ {
const QStringList options(parsedLine.mid(optionsNumber + 1).split(QL1C(',')));
parsedLine = parsedLine.left(optionsNumber);
if (options.contains(QL1S("match-case")))
m_regExp.setCaseSensitivity(Qt::CaseSensitive);
- foreach (const QString &option, options) {
+ foreach(const QString &option, options)
+ {
// Domain restricted filter
const QString domainKeyword(QL1S("domain="));
- if (option.startsWith(domainKeyword)) {
+ if (option.startsWith(domainKeyword))
+ {
QStringList domainList = option.mid(domainKeyword.length()).split(QL1C('|'));
- foreach (const QString &domain, domainList) {
+ foreach(const QString &domain, domainList)
+ {
if (domain.startsWith(QL1C('~')))
m_whiteDomains.insert(domain.toLower());
else
@@ -83,18 +87,22 @@ bool AdBlockRuleFallbackImpl::match(const QNetworkRequest &request, const QStrin
{
const bool regexpMatch = m_regExp.indexIn(encodedUrl) != -1;
- if (regexpMatch && (!m_whiteDomains.isEmpty() || !m_blackDomains.isEmpty())) {
+ if (regexpMatch && (!m_whiteDomains.isEmpty() || !m_blackDomains.isEmpty()))
+ {
Q_ASSERT(qobject_cast<QWebFrame*>(request.originatingObject()));
- const QWebFrame *const origin = static_cast<QWebFrame *const>(request.originatingObject());
+ const QWebFrame *const origin = static_cast<QWebFrame * const>(request.originatingObject());
const QString originDomain = origin->url().host();
- if (!m_whiteDomains.isEmpty()) {
+ if (!m_whiteDomains.isEmpty())
+ {
// In this context, white domains means we block anything but what is in the list.
if (m_whiteDomains.contains(originDomain))
return false;
return true;
- } else if (m_blackDomains.contains(originDomain)) {
+ }
+ else if (m_blackDomains.contains(originDomain))
+ {
return true;
}
return false;