Improve bad filter detection in element picker

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1280
This commit is contained in:
Raymond Hill 2020-10-08 09:49:35 -04:00
parent 11b9f88b38
commit c3f267db8f
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -71,9 +71,17 @@ const filterFromTextarea = function() {
if ( s === '' ) { return ''; }
const pos = s.indexOf('\n');
const filter = pos === -1 ? s.trim() : s.slice(0, pos).trim();
staticFilteringParser.analyze(filter);
staticFilteringParser.analyzeExtra();
return staticFilteringParser.shouldDiscard() ? '!' : filter;
const sfp = staticFilteringParser;
sfp.analyze(filter);
sfp.analyzeExtra();
if (
sfp.category !== sfp.CATStaticExtFilter &&
sfp.category !== sfp.CATStaticNetFilter ||
sfp.shouldDiscard()
) {
return '!';
}
return filter;
};
/******************************************************************************/