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

Delta Between Two Patch Sets: compiled/filter/Filter.cpp

Issue 29595633: Issue 5870 - Implement the new ElemHideEmulation filter type (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Addressed failing test: selector index was improperly adjusted. Created Feb. 7, 2018, 3:49 p.m.
Right Patch Set: Deal with ill formed filters. Created Feb. 14, 2018, 5:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } data; 108 } data;
109 bool needConversion = false; 109 bool needConversion = false;
110 DependentString error; 110 DependentString error;
111 111
112 Filter::Type type = CommentFilter::Parse(text); 112 Filter::Type type = CommentFilter::Parse(text);
113 if (type == Filter::Type::UNKNOWN) 113 if (type == Filter::Type::UNKNOWN)
114 type = ElemHideBase::Parse(text, data.elemhide, needConversion); 114 type = ElemHideBase::Parse(text, data.elemhide, needConversion);
115 if (type == Filter::Type::UNKNOWN) 115 if (type == Filter::Type::UNKNOWN)
116 type = RegExpFilter::Parse(text, error, data.regexp); 116 type = RegExpFilter::Parse(text, error, data.regexp);
117 117
118 if (needConversion && (type == ElemHideException::classType || type == ElemHid eEmulationFilter::classType)) 118 if (needConversion)
119 text = ElemHideBase::ConvertFilter(text, data.elemhide.mSelectorStart); 119 text = ElemHideBase::ConvertFilter(text, data.elemhide.mSelectorStart);
120 120
121 // At that point we failed the conversion. 121 // At that point we failed the conversion.
122 if (text.empty()) 122 if (text.empty())
123 return nullptr; 123 return nullptr;
124 124
125 auto knownFilter = knownFilters.find(text); 125 auto knownFilter = knownFilters.find(text);
126 if (knownFilter) 126 if (knownFilter)
127 { 127 {
128 knownFilter->second->AddRef(); 128 knownFilter->second->AddRef();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 knownFilters[filter->mText] = filter.get(); 165 knownFilters[filter->mText] = filter.get();
166 else 166 else
167 // This is a hack: we looked up the entry using text but create it using 167 // This is a hack: we looked up the entry using text but create it using
168 // filter->mText. This works because both are equal at this point. However, 168 // filter->mText. This works because both are equal at this point. However,
169 // text refers to a temporary buffer which will go away. 169 // text refers to a temporary buffer which will go away.
170 knownFilter.assign(filter->mText, filter.get()); 170 knownFilter.assign(filter->mText, filter.get());
171 exit_context(); 171 exit_context();
172 172
173 return filter.release(); 173 return filter.release();
174 } 174 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld