From 5f623dcfc8f02504d745f47f8b9274b2bca5fd67 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 18 Oct 2018 23:39:28 +0200 Subject: urlfilter: destroy FilterLeaves only when destroying the FilterTree Add QMutex lock when adding rules clang-format pass --- lib/urlfilter/formats/adblockrule.cpp | 4 ++-- lib/urlfilter/formats/adblockrule.h | 1 - lib/urlfilter/formats/hostlistrule.cpp | 11 +++++------ 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'lib/urlfilter/formats') 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; } - -- cgit v1.2.1