diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-10-18 23:39:28 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-10-19 00:30:13 +0200 |
commit | 5f623dcfc8f02504d745f47f8b9274b2bca5fd67 (patch) | |
tree | f7d6719f6c48c6c038e41631727ccc2ea3368461 /lib/urlfilter/formats | |
parent | urlfilter: add Domain class (diff) | |
download | smolbote-5f623dcfc8f02504d745f47f8b9274b2bca5fd67.tar.xz |
urlfilter: destroy FilterLeaves only when destroying the FilterTree
Add QMutex lock when adding rules
clang-format pass
Diffstat (limited to 'lib/urlfilter/formats')
-rw-r--r-- | lib/urlfilter/formats/adblockrule.cpp | 4 | ||||
-rw-r--r-- | lib/urlfilter/formats/adblockrule.h | 1 | ||||
-rw-r--r-- | lib/urlfilter/formats/hostlistrule.cpp | 11 |
3 files changed, 7 insertions, 9 deletions
diff --git a/lib/urlfilter/formats/adblockrule.cpp b/lib/urlfilter/formats/adblockrule.cpp index fc57ab9..c5d6b58 100644 --- a/lib/urlfilter/formats/adblockrule.cpp +++ b/lib/urlfilter/formats/adblockrule.cpp @@ -49,8 +49,8 @@ AdBlockRule::AdBlockRule(const QString &filter) for(const QString &option : options) { if(option.startsWith(QLatin1Literal("domain"))) { const auto domainList = option.mid(7).split(QLatin1Literal("|")); - for (const QString &domain : domainList) { - if (domain.startsWith(QLatin1Literal("~"))) { + for(const QString &domain : domainList) { + if(domain.startsWith(QLatin1Literal("~"))) { blockedDomains_hashes.append(qHash(domain.mid(1))); } else { allowedDomains_hashes.append(qHash(domain)); diff --git a/lib/urlfilter/formats/adblockrule.h b/lib/urlfilter/formats/adblockrule.h index 95cd1a2..3c8edb1 100644 --- a/lib/urlfilter/formats/adblockrule.h +++ b/lib/urlfilter/formats/adblockrule.h @@ -17,7 +17,6 @@ public: explicit AdBlockRule(const QString &filter); void parseOption(const QString &option); - }; #endif // SMOLBOTE_ADBLOCKRULE_H diff --git a/lib/urlfilter/formats/hostlistrule.cpp b/lib/urlfilter/formats/hostlistrule.cpp index 8336243..f0cb4af 100644 --- a/lib/urlfilter/formats/hostlistrule.cpp +++ b/lib/urlfilter/formats/hostlistrule.cpp @@ -8,16 +8,16 @@ #include "hostlistrule.h" -HostlistRule::HostlistRule(const QString &domain, const QString& redirect) +HostlistRule::HostlistRule(const QString &domain, const QString &redirect) { this->m_isBlocking = (redirect == QLatin1Literal("0.0.0.0")); - this->m_request = domain.toStdString(); - this->m_redirect = redirect.toStdString(); + this->m_request = domain; + this->m_redirect = redirect; } -bool HostlistRule::match(const QString& requestUrl) const +bool HostlistRule::match(const QString &requestUrl) const { - return (m_request == requestUrl.toStdString()); + return (m_request == requestUrl); } FilterLeaf::Action HostlistRule::action() const @@ -26,4 +26,3 @@ FilterLeaf::Action HostlistRule::action() const return FilterLeaf::Block; return FilterLeaf::Redirect; } - |