1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-02 23:57:10 +02:00

AMO review: keep dev console clean

This commit is contained in:
gorhill 2016-03-27 09:24:57 -04:00
parent db09f83e2f
commit 6095a1db0f

View File

@ -372,21 +372,17 @@ FilterParser.prototype.parse = function(raw) {
switch ( matches[1] ) { switch ( matches[1] ) {
case 'contains': case 'contains':
this.suffix = 'script?';
// Plain string- or regex-based? // Plain string- or regex-based?
if ( token.startsWith('/') === false || token.endsWith('/') === false ) { if ( token.startsWith('/') === false || token.endsWith('/') === false ) {
this.suffix += token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); token = token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
} else { } else {
this.suffix += token.slice(1, -1); token = token.slice(1, -1);
if ( isBadRegex(this.suffix) ) { if ( isBadRegex(token) ) {
console.error( µb.logger.writeOne('', 'error', 'Cosmetic filtering bad regular expression: ' + raw + ' (' + isBadRegex.message + ')');
"uBlock Origin> discarding bad regular expression-based cosmetic filter '%s': '%s'",
raw,
isBadRegex.message
);
this.invalid = true; this.invalid = true;
} }
} }
this.suffix = 'script?' + token;
break; break;
case 'inject': case 'inject':
this.suffix = 'script+' + token; this.suffix = 'script+' + token;
@ -706,7 +702,7 @@ FilterContainer.prototype.isValidSelector = (function() {
return true; return true;
} }
} }
console.error('uBlock> invalid cosmetic filter:', s); µb.logger.writeOne('', 'error', 'Cosmetic filtering invalid filter: ' + s);
return false; return false;
}; };
})(); })();