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

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

Issue 29595633: Issue 5870 - Implement the new ElemHideEmulation filter type (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Refactor consts Created Feb. 1, 2018, 11:30 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 case BlockingFilter::classType: 131 case BlockingFilter::classType:
132 filter = FilterPtr(new BlockingFilter(text, data.regexp), false); 132 filter = FilterPtr(new BlockingFilter(text, data.regexp), false);
133 break; 133 break;
134 case WhitelistFilter::classType: 134 case WhitelistFilter::classType:
135 filter = FilterPtr(new WhitelistFilter(text, data.regexp), false); 135 filter = FilterPtr(new WhitelistFilter(text, data.regexp), false);
136 break; 136 break;
137 case ElemHideFilter::classType: 137 case ElemHideFilter::classType:
138 filter = FilterPtr(new ElemHideFilter(text, data.elemhide), false); 138 filter = FilterPtr(new ElemHideFilter(text, data.elemhide), false);
139 break; 139 break;
140 case ElemHideException::classType: 140 case ElemHideException::classType:
141 filter = FilterPtr(new ElemHideException(text, data.elemhide), false); 141 filter = FilterPtr(
142 new ElemHideException(
143 data.elemhide.mNeedConversion ?
144 DependentString(ElemHideBase::ConvertFilter(text, data.elemhide.mSelec torStart)) :
145 text, data.elemhide), false);
142 break; 146 break;
143 case ElemHideEmulationFilter::classType: 147 case ElemHideEmulationFilter::classType:
144 filter = FilterPtr(new ElemHideEmulationFilter(text, data.elemhide), false ); 148 filter = FilterPtr(
149 new ElemHideEmulationFilter(
150 data.elemhide.mNeedConversion ?
151 DependentString(ElemHideBase::ConvertFilter(text, data.elemhide.mSelec torStart)) :
152 text, data.elemhide), false);
145 if (static_cast<ElemHideEmulationFilter*>(filter.get())->IsGeneric()) 153 if (static_cast<ElemHideEmulationFilter*>(filter.get())->IsGeneric())
146 filter = FilterPtr(new InvalidFilter(text, u"filter_elemhideemulation_no domain"_str), false); 154 filter = FilterPtr(new InvalidFilter(text, u"filter_elemhideemulation_no domain"_str), false);
147 break; 155 break;
148 default: 156 default:
149 // This should never happen but just in case 157 // This should never happen but just in case
150 return nullptr; 158 return nullptr;
151 } 159 }
152 160
153 // This is a hack: we looked up the entry using text but create it using
154 // filter->mText. This works because both are equal at this point. However,
155 // text refers to a temporary buffer which will go away.
156 enter_context("Adding to known filters"); 161 enter_context("Adding to known filters");
157 knownFilter.assign(filter->mText, filter.get()); 162 if (text != filter->mText)
163 knownFilters[filter->mText] = filter.get();
164 else
165 // This is a hack: we looked up the entry using text but create it using
166 // filter->mText. This works because both are equal at this point. However,
167 // text refers to a temporary buffer which will go away.
168 knownFilter.assign(filter->mText, filter.get());
158 exit_context(); 169 exit_context();
159 170
160 return filter.release(); 171 return filter.release();
161 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld