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

Side by Side Diff: compiled/filter/ElemHideBase.cpp

Issue 29595633: Issue 5870 - Implement the new ElemHideEmulation filter type (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Nov. 2, 2017, 11:42 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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 case u'"': 80 case u'"':
81 case u'!': 81 case u'!':
82 return Type::UNKNOWN; 82 return Type::UNKNOWN;
83 case u' ': 83 case u' ':
84 seenSpaces = true; 84 seenSpaces = true;
85 break; 85 break;
86 } 86 }
87 } 87 }
88 88
89 seenSpaces |= scanner.skip(u' '); 89 seenSpaces |= scanner.skip(u' ');
90 bool emulation = false;
90 bool exception = scanner.skipOne(u'@'); 91 bool exception = scanner.skipOne(u'@');
91 if (exception) 92 if (exception)
92 seenSpaces |= scanner.skip(u' '); 93 seenSpaces |= scanner.skip(u' ');
94 else
95 emulation = scanner.skipOne(u'?');
93 96
94 String::value_type next = scanner.next(); 97 String::value_type next = scanner.next();
95 if (next != u'#') 98 if (next != u'#')
96 return Type::UNKNOWN; 99 return Type::UNKNOWN;
97 100
98 // Selector part 101 // Selector part
99 102
100 // Selector shouldn't be empty 103 // Selector shouldn't be empty
101 seenSpaces |= scanner.skip(u' '); 104 seenSpaces |= scanner.skip(u' ');
102 if (scanner.done()) 105 if (scanner.done())
(...skipping 11 matching lines...) Expand all
114 } 117 }
115 118
116 // We are done validating, now we can normalize whitespace and the domain part 119 // We are done validating, now we can normalize whitespace and the domain part
117 if (seenSpaces) 120 if (seenSpaces)
118 NormalizeWhitespace(text, data.mDomainsEnd, data.mSelectorStart); 121 NormalizeWhitespace(text, data.mDomainsEnd, data.mSelectorStart);
119 DependentString(text, 0, data.mDomainsEnd).toLower(); 122 DependentString(text, 0, data.mDomainsEnd).toLower();
120 123
121 if (exception) 124 if (exception)
122 return Type::ELEMHIDEEXCEPTION; 125 return Type::ELEMHIDEEXCEPTION;
123 126
124 if (text.find(u"[-abp-properties="_str, data.mSelectorStart) != text.npos) 127 if (emulation)
125 return Type::ELEMHIDEEMULATION; 128 return Type::ELEMHIDEEMULATION;
126 129
127 return Type::ELEMHIDE; 130 return Type::ELEMHIDE;
128 } 131 }
129 132
130 OwnedString ElemHideBase::GetSelectorDomain() const 133 OwnedString ElemHideBase::GetSelectorDomain() const
131 { 134 {
132 /* TODO this is inefficient */ 135 /* TODO this is inefficient */
133 OwnedString result; 136 OwnedString result;
134 if (mDomains) 137 if (mDomains)
135 { 138 {
136 for (const auto& item : *mDomains) 139 for (const auto& item : *mDomains)
137 { 140 {
138 if (item.second && !item.first.empty()) 141 if (item.second && !item.first.empty())
139 { 142 {
140 if (!result.empty()) 143 if (!result.empty())
141 result.append(u','); 144 result.append(u',');
142 result.append(item.first); 145 result.append(item.first);
143 } 146 }
144 } 147 }
145 } 148 }
146 return result; 149 return result;
147 } 150 }
OLDNEW
« no previous file with comments | « no previous file | compiled/filter/ElemHideEmulationFilter.cpp » ('j') | compiled/filter/ElemHideEmulationFilter.cpp » ('J')

Powered by Google App Engine
This is Rietveld