From 608135ac95b1ef555eeb1beda21c099c07b3d16a Mon Sep 17 00:00:00 2001 From: nowrep Date: Mon, 2 Jul 2012 09:58:56 +0200 Subject: [PATCH] AdBlock: Using QString::endsWith in domain matching - instead of QString::contains --- src/lib/adblock/adblockrule.cpp | 10 +++++----- src/lib/cookies/cookiejar.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/adblock/adblockrule.cpp b/src/lib/adblock/adblockrule.cpp index 5a2b48428..2816e3e26 100644 --- a/src/lib/adblock/adblockrule.cpp +++ b/src/lib/adblock/adblockrule.cpp @@ -195,7 +195,7 @@ bool AdBlockRule::networkMatch(const QNetworkRequest &request, const QString &do matched = (m_regExp.indexIn(encodedUrl) != -1); } else if (m_useDomainMatch) { - matched = domain.contains(m_matchString); + matched = domain.endsWith(m_matchString); } else if (m_useEndsMatch) { matched = encodedUrl.endsWith(m_matchString, m_caseSensitivity); @@ -242,14 +242,14 @@ bool AdBlockRule::matchDomain(const QString &domain) const if (m_blockedDomains.isEmpty()) { foreach(const QString & d, m_allowedDomains) { - if (domain.contains(d)) { + if (domain.endsWith(d)) { return true; } } } else if (m_allowedDomains.isEmpty()) { foreach(const QString & d, m_blockedDomains) { - if (domain.contains(d)) { + if (domain.endsWith(d)) { return false; } } @@ -257,13 +257,13 @@ bool AdBlockRule::matchDomain(const QString &domain) const } else { foreach(const QString & d, m_blockedDomains) { - if (domain.contains(d)) { + if (domain.endsWith(d)) { return false; } } foreach(const QString & d, m_allowedDomains) { - if (domain.contains(d)) { + if (domain.endsWith(d)) { return true; } } diff --git a/src/lib/cookies/cookiejar.cpp b/src/lib/cookies/cookiejar.cpp index ed9b18b94..27ae69ee7 100644 --- a/src/lib/cookies/cookiejar.cpp +++ b/src/lib/cookies/cookiejar.cpp @@ -35,7 +35,7 @@ bool containsDomain(QString string, QString domain) domain = domain.mid(4); } - return string.contains(domain); + return string.endsWith(domain); } bool listContainsDomain(const QStringList &list, const QString &domain)