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

Unified Diff: compiled/filter/ElemHideBase.cpp

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.
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.h ('k') | compiled/filter/ElemHideEmulationFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/filter/ElemHideBase.cpp
===================================================================
--- a/compiled/filter/ElemHideBase.cpp
+++ b/compiled/filter/ElemHideBase.cpp
@@ -61,24 +61,26 @@
static constexpr String::value_type OLD_PROPS_SELECTOR[] = u"[-abp-properties=";
static constexpr String::size_type OLD_PROPS_SELECTOR_LEN = str_length_of(OLD_PROPS_SELECTOR);
static constexpr String::value_type PROPS_SELECTOR[] = u":-abp-properties(";
static constexpr String::size_type PROPS_SELECTOR_LEN = str_length_of(PROPS_SELECTOR);
}
-ElemHideBase::ElemHideBase(Type type, const String& text, const ElemHideData& data)
+ElemHideBase::ElemHideBase(Type type, const String& text, const ElemHideData& data, const ParsedDomains& parsedDomains)
: ActiveFilter(type, text, false), mData(data)
{
if (mData.HasDomains())
- ParseDomains(mData.GetDomainsSource(mText), u',');
+ FillDomains(mData.GetDomainsSource(mText), parsedDomains);
}
-Filter::Type ElemHideBase::Parse(DependentString& text, ElemHideData& data, bool& needConversion)
+Filter::Type ElemHideBase::Parse(DependentString& text, DependentString& error,
+ ElemHideData& data, bool& needConversion,
+ ParsedDomains& parsedDomains)
{
needConversion = false;
StringScanner scanner(text);
// Domains part
bool seenSpaces = false;
while (!scanner.done())
@@ -126,16 +128,23 @@
data.mSelectorStart = scanner.position() + 1;
// We are done validating, now we can normalize whitespace and the domain part
if (seenSpaces)
NormalizeWhitespace(text, data.mDomainsEnd, data.mSelectorStart);
DependentString(text, 0, data.mDomainsEnd).toLower();
+ parsedDomains =
+ ParseDomainsInternal(data.GetDomainsSource(text), u',', false);
+ if (parsedDomains.hasEmpty)
+ {
+ error = u"filter_invalid_domain"_str;
+ return Type::INVALID;
+ }
// We still need to check the old syntax. It will be converted when
// we instantiate the filter.
if (!emulation &&
text.find(OLD_PROPS_SELECTOR, data.mSelectorStart, OLD_PROPS_SELECTOR_LEN) != text.npos)
{
needConversion = true;
emulation = !exception;
}
« no previous file with comments | « compiled/filter/ElemHideBase.h ('k') | compiled/filter/ElemHideEmulationFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld