Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: compiled/filter/ActiveFilter.h

Issue 29600641: Issue 5175 - Reject element hiding filter with empty domain names (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Make the new test more functional Created March 6, 2018, 7:47 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | compiled/filter/ActiveFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 25 matching lines...) Expand all
36 if (name != value)\ 36 if (name != value)\
37 {\ 37 {\
38 name = value;\ 38 name = value;\
39 if (ABP_NS::FilterNotifier::Topic::topic != ABP_NS::FilterNotifier::To pic::NONE)\ 39 if (ABP_NS::FilterNotifier::Topic::topic != ABP_NS::FilterNotifier::To pic::NONE)\
40 {\ 40 {\
41 ABP_NS::FilterNotifier::FilterChange(ABP_NS::FilterNotifier::Topic:: topic, *this);\ 41 ABP_NS::FilterNotifier::FilterChange(ABP_NS::FilterNotifier::Topic:: topic, *this);\
42 }\ 42 }\
43 }\ 43 }\
44 } 44 }
45 45
46
46 ABP_NS_BEGIN 47 ABP_NS_BEGIN
47 48
49 struct ParsedDomains
50 {
51 struct Domain {
52 String::size_type pos;
53 String::size_type len;
54 bool reverse;
55 };
56 bool hasIncludes;
57 bool hasEmpty;
58 std::vector<Domain> domains;
59
60 ParsedDomains()
61 : hasIncludes(false), hasEmpty(false)
62 {
63 }
64 };
65
48 class ActiveFilter : public Filter 66 class ActiveFilter : public Filter
49 { 67 {
50 public: 68 public:
51 typedef StringMap<bool> DomainMap; 69 typedef StringMap<bool> DomainMap;
52 virtual DomainMap* GetDomains() const; 70 virtual DomainMap* GetDomains() const;
53 static const DependentString DEFAULT_DOMAIN; 71 static const DependentString DEFAULT_DOMAIN;
54 protected: 72 protected:
55 typedef StringSet SitekeySet; 73 typedef StringSet SitekeySet;
56 void ParseDomains(const String& domains, String::value_type separator) const; 74 static ParsedDomains ParseDomainsInternal(const String& domains,
75 String::value_type separator, bool ignoreTrailingDot);
76 void FillDomains(const String& domains, const ParsedDomains& parsed) const;
77 void ParseDomains(const String& domains,
78 String::value_type separator, bool ignoreTrailingDot) const;
57 void AddSitekey(const String& sitekey) const; 79 void AddSitekey(const String& sitekey) const;
58 virtual SitekeySet* GetSitekeys() const; 80 virtual SitekeySet* GetSitekeys() const;
59 mutable std::unique_ptr<DomainMap> mDomains; 81 mutable std::unique_ptr<DomainMap> mDomains;
60 mutable std::unique_ptr<SitekeySet> mSitekeys; 82 mutable std::unique_ptr<SitekeySet> mSitekeys;
61 private: 83 private:
62 bool mIgnoreTrailingDot; 84 bool mIgnoreTrailingDot;
63 public: 85 public:
64 static constexpr Type classType = Type::ACTIVE; 86 static constexpr Type classType = Type::ACTIVE;
65 explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot); 87 explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot);
66 FILTER_PROPERTY(bool, mDisabled, FILTER_DISABLED, GetDisabled, SetDisabled); 88 FILTER_PROPERTY(bool, mDisabled, FILTER_DISABLED, GetDisabled, SetDisabled);
67 FILTER_PROPERTY(unsigned int, mHitCount, FILTER_HITCOUNT, 89 FILTER_PROPERTY(unsigned int, mHitCount, FILTER_HITCOUNT,
68 GetHitCount, SetHitCount); 90 GetHitCount, SetHitCount);
69 FILTER_PROPERTY(unsigned int, mLastHit, FILTER_LASTHIT, 91 FILTER_PROPERTY(unsigned int, mLastHit, FILTER_LASTHIT,
70 GetLastHit, SetLastHit); 92 GetLastHit, SetLastHit);
71 bool BINDINGS_EXPORTED IsActiveOnDomain(DependentString& docDomain, 93 bool BINDINGS_EXPORTED IsActiveOnDomain(DependentString& docDomain,
72 const String& sitekey = DependentString()) const; 94 const String& sitekey = DependentString()) const;
73 bool BINDINGS_EXPORTED IsActiveOnlyOnDomain(DependentString& docDomain) const; 95 bool BINDINGS_EXPORTED IsActiveOnlyOnDomain(DependentString& docDomain) const;
74 bool BINDINGS_EXPORTED IsGeneric() const; 96 bool BINDINGS_EXPORTED IsGeneric() const;
75 OwnedString BINDINGS_EXPORTED Serialize() const; 97 OwnedString BINDINGS_EXPORTED Serialize() const;
76 }; 98 };
77 99
78 typedef intrusive_ptr<ActiveFilter> ActiveFilterPtr; 100 typedef intrusive_ptr<ActiveFilter> ActiveFilterPtr;
79 101
80 ABP_NS_END 102 ABP_NS_END
OLDNEW
« no previous file with comments | « no previous file | compiled/filter/ActiveFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld