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
1 changed files with 11 additions and 3 deletions

View File

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