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 = LENGTH_OF(OLD_PROPS_SELECTOR); |
static constexpr String::value_type PROPS_SELECTOR[] = u":-abp-properties("; |
static constexpr String::size_type PROPS_SELECTOR_LEN = 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) |
{ |
StringScanner scanner(text); |
// Domains part |
bool seenSpaces = false; |
while (!scanner.done()) |
{ |
String::value_type next = scanner.next(); |
@@ -124,16 +126,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; |
} |