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

Unified 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: Reworked the strings const. String::find() from a String::value_type* Created Feb. 1, 2018, 8:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compiled/filter/ElemHideBase.cpp ('k') | meson.build » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/filter/Filter.cpp
===================================================================
--- a/compiled/filter/Filter.cpp
+++ b/compiled/filter/Filter.cpp
@@ -133,29 +133,40 @@
break;
case WhitelistFilter::classType:
filter = FilterPtr(new WhitelistFilter(text, data.regexp), false);
break;
case ElemHideFilter::classType:
filter = FilterPtr(new ElemHideFilter(text, data.elemhide), false);
break;
case ElemHideException::classType:
- filter = FilterPtr(new ElemHideException(text, data.elemhide), false);
+ filter = FilterPtr(
+ new ElemHideException(
+ data.elemhide.mNeedConversion ?
+ DependentString(ElemHideBase::ConvertFilter(text, data.elemhide.mSelectorStart)) :
+ text, data.elemhide), false);
break;
case ElemHideEmulationFilter::classType:
- filter = FilterPtr(new ElemHideEmulationFilter(text, data.elemhide), false);
+ filter = FilterPtr(
+ new ElemHideEmulationFilter(
+ data.elemhide.mNeedConversion ?
+ DependentString(ElemHideBase::ConvertFilter(text, data.elemhide.mSelectorStart)) :
+ text, data.elemhide), false);
if (static_cast<ElemHideEmulationFilter*>(filter.get())->IsGeneric())
filter = FilterPtr(new InvalidFilter(text, u"filter_elemhideemulation_nodomain"_str), false);
break;
default:
// This should never happen but just in case
return nullptr;
}
- // This is a hack: we looked up the entry using text but create it using
- // filter->mText. This works because both are equal at this point. However,
- // text refers to a temporary buffer which will go away.
enter_context("Adding to known filters");
- knownFilter.assign(filter->mText, filter.get());
+ if (text != filter->mText)
+ knownFilters[filter->mText] = filter.get();
+ else
+ // This is a hack: we looked up the entry using text but create it using
+ // filter->mText. This works because both are equal at this point. However,
+ // text refers to a temporary buffer which will go away.
+ knownFilter.assign(filter->mText, filter.get());
exit_context();
return filter.release();
}
« no previous file with comments | « compiled/filter/ElemHideBase.cpp ('k') | meson.build » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld