mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
AdBlock: Using QString::endsWith in domain matching
- instead of QString::contains
This commit is contained in:
parent
5b68deba48
commit
608135ac95
@ -195,7 +195,7 @@ bool AdBlockRule::networkMatch(const QNetworkRequest &request, const QString &do
|
|||||||
matched = (m_regExp.indexIn(encodedUrl) != -1);
|
matched = (m_regExp.indexIn(encodedUrl) != -1);
|
||||||
}
|
}
|
||||||
else if (m_useDomainMatch) {
|
else if (m_useDomainMatch) {
|
||||||
matched = domain.contains(m_matchString);
|
matched = domain.endsWith(m_matchString);
|
||||||
}
|
}
|
||||||
else if (m_useEndsMatch) {
|
else if (m_useEndsMatch) {
|
||||||
matched = encodedUrl.endsWith(m_matchString, m_caseSensitivity);
|
matched = encodedUrl.endsWith(m_matchString, m_caseSensitivity);
|
||||||
@ -242,14 +242,14 @@ bool AdBlockRule::matchDomain(const QString &domain) const
|
|||||||
|
|
||||||
if (m_blockedDomains.isEmpty()) {
|
if (m_blockedDomains.isEmpty()) {
|
||||||
foreach(const QString & d, m_allowedDomains) {
|
foreach(const QString & d, m_allowedDomains) {
|
||||||
if (domain.contains(d)) {
|
if (domain.endsWith(d)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_allowedDomains.isEmpty()) {
|
else if (m_allowedDomains.isEmpty()) {
|
||||||
foreach(const QString & d, m_blockedDomains) {
|
foreach(const QString & d, m_blockedDomains) {
|
||||||
if (domain.contains(d)) {
|
if (domain.endsWith(d)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,13 +257,13 @@ bool AdBlockRule::matchDomain(const QString &domain) const
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach(const QString & d, m_blockedDomains) {
|
foreach(const QString & d, m_blockedDomains) {
|
||||||
if (domain.contains(d)) {
|
if (domain.endsWith(d)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QString & d, m_allowedDomains) {
|
foreach(const QString & d, m_allowedDomains) {
|
||||||
if (domain.contains(d)) {
|
if (domain.endsWith(d)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ bool containsDomain(QString string, QString domain)
|
|||||||
domain = domain.mid(4);
|
domain = domain.mid(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.contains(domain);
|
return string.endsWith(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool listContainsDomain(const QStringList &list, const QString &domain)
|
bool listContainsDomain(const QStringList &list, const QString &domain)
|
||||||
|
Loading…
Reference in New Issue
Block a user