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: Rebased Created Dec. 5, 2017, 6:06 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
@@ -137,25 +137,27 @@
return converted;
}
return OwnedString(text);
}
}
-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, ConvertFilter(text, data.mSelectorStart), false),
mData(data)
{
if (mData.HasDomains())
- ParseDomains(mData.GetDomainsSource(mText), u',');
+ FillDomains(mData.GetDomainsSource(mText), parsedDomains);
}
-Filter::Type ElemHideBase::Parse(DependentString& text, ElemHideData& data)
+Filter::Type ElemHideBase::Parse(DependentString& text, DependentString& error,
+ ElemHideData& data, ParsedDomains& parsedDomains)
{
StringScanner scanner(text);
// Domains part
bool seenSpaces = false;
while (!scanner.done())
{
String::value_type next = scanner.next();
@@ -201,16 +203,24 @@
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;
+ }
+
if (exception)
return Type::ELEMHIDEEXCEPTION;
if (emulation)
return Type::ELEMHIDEEMULATION;
return Type::ELEMHIDE;
}
« 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