1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

AdBlock: Using QString::endsWith in domain matching

- instead of QString::contains
This commit is contained in:
nowrep 2012-07-02 09:58:56 +02:00
parent 5b68deba48
commit 608135ac95
2 changed files with 6 additions and 6 deletions

View File

@ -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;
}
}

View File

@ -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)